Less ambiguous behavior when failing to load openIndexes (cf. #27)

This commit is contained in:
Olivier Keshavjee 2016-04-18 11:46:07 +02:00
parent 085a9e4a2d
commit c6cace1a9b
2 changed files with 9 additions and 5 deletions

View file

@ -72,6 +72,11 @@ class mainEditor(QWidget, Ui_mainEditor):
else:
ts = ts.secondTab
# No tabSplitter has focus, something is strange.
# But probably not important.
# Let's return self.tabSplitter.tab anyway.
return self.tabSplitter.tab
def currentEditor(self, tabWidget=None):
if tabWidget is None:
tabWidget = self.currentTabWidget()
@ -163,11 +168,11 @@ class mainEditor(QWidget, Ui_mainEditor):
if qApp.keyboardModifiers() & Qt.ControlModifier:
newTab = True
if newTab or not self.currentTabWidget().count():
if newTab or not tabWidget.count():
editor = editorWidget(self)
editor.setCurrentModelIndex(index)
tabWidget.addTab(editor, title)
tabWidget.setCurrentIndex(self.currentTabWidget().count() - 1)
tabWidget.setCurrentIndex(tabWidget.count() - 1)
else:
self.currentEditor(tabWidget).setCurrentModelIndex(index)
tabWidget.setTabText(tabWidget.currentIndex(), title)

View file

@ -102,9 +102,8 @@ class tabSplitter(QWidget, Ui_tabSplitter):
self.secondTab.restoreOpenIndexes(openIndexes[2])
except:
print("Failed to load indexes from settings...")
print("Indexes:", openIndexes)
# Cannot load open indexes. Let's simply open root.
self.mainEditor.setCurrentModelIndex(QModelIndex(), newTab=True)
###############################################################################
# TARGET