Python console widget: Save registry fix (#6076)

* it is possible to call 'save_registry' only when window is showed up

* used more clever way how to determine if should be saved
This commit is contained in:
Jakub Trllo 2023-12-20 18:34:37 +01:00 committed by GitHub
parent 9ea90962c8
commit 64d39613fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -354,7 +354,7 @@ class PythonInterpreterWidget(QtWidgets.QWidget):
default_width = 1000
default_height = 600
def __init__(self, parent=None):
def __init__(self, allow_save_registry=True, parent=None):
super(PythonInterpreterWidget, self).__init__(parent)
self.setWindowTitle("{} Console".format(
@ -414,6 +414,8 @@ class PythonInterpreterWidget(QtWidgets.QWidget):
self._first_show = True
self._splitter_size_ratio = None
self._allow_save_registry = allow_save_registry
self._registry_saved = True
self._init_from_registry()
@ -457,6 +459,11 @@ class PythonInterpreterWidget(QtWidgets.QWidget):
pass
def save_registry(self):
# Window was not showed
if not self._allow_save_registry or self._registry_saved:
return
self._registry_saved = True
setting_registry = PythonInterpreterRegistry()
setting_registry.set_item("width", self.width())
@ -650,6 +657,7 @@ class PythonInterpreterWidget(QtWidgets.QWidget):
def showEvent(self, event):
self._line_check_timer.start()
self._registry_saved = False
super(PythonInterpreterWidget, self).showEvent(event)
# First show setup
if self._first_show: