From 358de35300a3d08297500aa5cfe9266d26e8fecf Mon Sep 17 00:00:00 2001 From: David Vierra Date: Wed, 20 Jan 2016 03:09:24 -1000 Subject: [PATCH] Avoid creating world view when world list is offscreen. Seems to fix the access violations, but that's not at all certain. Hours of bisecting and single-stepping also blamed the simple import of one of the UI files for the violations. In any case, this avoids doubly creating the world view both when the window is initialized and when it is shown on screen. --- src/mcedit2/worldlist.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/mcedit2/worldlist.py b/src/mcedit2/worldlist.py index 33635ec..20404e7 100644 --- a/src/mcedit2/worldlist.py +++ b/src/mcedit2/worldlist.py @@ -201,7 +201,7 @@ class WorldListWidget(QtGui.QDialog, Ui_worldList): self._updateInstalls() - self.savesFolderComboBox.currentIndexChanged.connect(self.reloadList) + self.savesFolderComboBox.currentIndexChanged.connect(self.savesFolderChanged) self.minecraftInstallBox.currentIndexChanged.connect(minecraftinstall.currentInstallOption.setValue) self.minecraftVersionBox.currentIndexChanged[str].connect(minecraftinstall.currentVersionOption.setValue) self.resourcePackBox.currentIndexChanged.connect(self.resourcePackChanged) @@ -287,6 +287,15 @@ class WorldListWidget(QtGui.QDialog, Ui_worldList): self.recentWorldsButton.setMenu(self.recentWorldsMenu) + def savesFolderChanged(self): + self.reloadList() + if len(self.worldListModel.worlds): + self.worldListView.setFocus() + self.worldListView.setCurrentIndex(self.worldListModel.createIndex(0, 0)) + self.showWorld(self.worldListModel.worlds[0][0]) + else: + self.removeWorldView() + def reloadList(self): try: itemData = self.savesFolderComboBox.itemData(self.savesFolderComboBox.currentIndex()) @@ -308,11 +317,6 @@ class WorldListWidget(QtGui.QDialog, Ui_worldList): self.worldListModel = WorldListModel(worldFiles) self.worldListView.setModel(self.worldListModel) - if len(self.worldListModel.worlds): - self.worldListView.setFocus() - self.worldListView.setCurrentIndex(self.worldListModel.createIndex(0, 0)) - self.showWorld(self.worldListModel.worlds[0][0]) - except EnvironmentError as e: setWidgetError(self, e) @@ -323,9 +327,7 @@ class WorldListWidget(QtGui.QDialog, Ui_worldList): def worldListItemClicked(self, index): filename = index.data() - if filename != self._currentFilename: - self._currentFilename = filename - self.showWorld(filename) + self.showWorld(filename) def worldListItemDoubleClicked(self, index): row = index.row() @@ -333,6 +335,10 @@ class WorldListWidget(QtGui.QDialog, Ui_worldList): self.editWorldClicked.emit(self.worldListModel.worlds[row][0]) def showWorld(self, filename): + if filename == self._currentFilename: + return + self._currentFilename = filename + self.removeWorldView() try: