mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 19:28:07 -06:00
Only initialise AutoSave after Application finishes its start up
CURA-4895
This commit is contained in:
parent
30b1e74881
commit
c2aa5fc2a2
2 changed files with 24 additions and 2 deletions
|
@ -106,6 +106,14 @@ if not MYPY:
|
||||||
CuraDebugMode = False
|
CuraDebugMode = False
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# A global signal which is triggered when CuraApplication has finished its start up.
|
||||||
|
# This is used to initialise some plugins such as AutoSave which should only be started after the application passed
|
||||||
|
# the start up successfully.
|
||||||
|
#
|
||||||
|
applicationStarted = pyqtSignal()
|
||||||
|
|
||||||
|
|
||||||
class CuraApplication(QtApplication):
|
class CuraApplication(QtApplication):
|
||||||
# SettingVersion represents the set of settings available in the machine/extruder definitions.
|
# SettingVersion represents the set of settings available in the machine/extruder definitions.
|
||||||
# You need to make sure that this version number needs to be increased if there is any non-backwards-compatible
|
# You need to make sure that this version number needs to be increased if there is any non-backwards-compatible
|
||||||
|
|
|
@ -9,6 +9,7 @@ from UM.Application import Application
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
|
||||||
|
|
||||||
class AutoSave(Extension):
|
class AutoSave(Extension):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -16,8 +17,6 @@ class AutoSave(Extension):
|
||||||
Preferences.getInstance().preferenceChanged.connect(self._triggerTimer)
|
Preferences.getInstance().preferenceChanged.connect(self._triggerTimer)
|
||||||
|
|
||||||
self._global_stack = None
|
self._global_stack = None
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged)
|
|
||||||
self._onGlobalStackChanged()
|
|
||||||
|
|
||||||
Preferences.getInstance().addPreference("cura/autosave_delay", 1000 * 10)
|
Preferences.getInstance().addPreference("cura/autosave_delay", 1000 * 10)
|
||||||
|
|
||||||
|
@ -28,6 +27,21 @@ class AutoSave(Extension):
|
||||||
|
|
||||||
self._saving = False
|
self._saving = False
|
||||||
|
|
||||||
|
# At this point, the Application instance has not finished its constructor call yet, so directly using something
|
||||||
|
# like Application.getInstance() is not correct. The initialisation now will only gets triggered after the
|
||||||
|
# application finishes its start up successfully.
|
||||||
|
from cura.CuraApplication import applicationStarted
|
||||||
|
applicationStarted.connect(self.initialize)
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
from cura.CuraApplication import applicationStarted
|
||||||
|
applicationStarted.disconnect(self.initialize)
|
||||||
|
|
||||||
|
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged)
|
||||||
|
self._onGlobalStackChanged()
|
||||||
|
|
||||||
|
self._triggerTimer()
|
||||||
|
|
||||||
def _triggerTimer(self, *args):
|
def _triggerTimer(self, *args):
|
||||||
if not self._saving:
|
if not self._saving:
|
||||||
self._change_timer.start()
|
self._change_timer.start()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue