PICARD-1726: Moved widget deleted detection logic to OptionsPage

This commit is contained in:
Philipp Wolfer
2020-02-06 17:48:14 +01:00
parent d21eca5a25
commit 1ad55ebff0
2 changed files with 11 additions and 11 deletions

View File

@@ -44,6 +44,16 @@ class OptionsPage(QtWidgets.QWidget):
super().__init__(*args, **kwargs)
self.setStyleSheet(self.STYLESHEET)
# Keep track whether the options page has been destroyed to avoid
# trying to update deleted UI widgets after plugin list refresh.
self.deleted = False
# The on destroyed cannot be created as a method on this class or it will never get called.
# See https://stackoverflow.com/questions/16842955/widgets-destroyed-signal-is-not-fired-pyqt
def on_destroyed(obj=None):
self.deleted = True
self.destroyed.connect(on_destroyed)
def check(self):
pass

View File

@@ -235,16 +235,6 @@ class PluginsOptionsPage(OptionsPage):
self.ui.folder_open.clicked.connect(self.open_plugin_dir)
self.ui.reload_list_of_plugins.clicked.connect(self.reload_list_of_plugins)
# Keep track whether the object has been destroyed to avoid trying to update
# deleted UI widgets after plugin list refresh.
self._deleted = False
# The on destroyed cannot be created as a method on this class or it will never get called.
# See https://stackoverflow.com/questions/16842955/widgets-destroyed-signal-is-not-fired-pyqt
def on_destroyed(obj=None):
self._deleted = True
self.destroyed.connect(on_destroyed)
self.manager = self.tagger.pluginmanager
self.manager.plugin_installed.connect(self.plugin_installed)
self.manager.plugin_updated.connect(self.plugin_updated)
@@ -383,7 +373,7 @@ class PluginsOptionsPage(OptionsPage):
self.set_current_item(item, scroll=True)
def _reload(self):
if self._deleted:
if self.deleted:
return
self._remove_all()
self._populate()