From bdc8fdf508fdcbe13836de26d350f5f5cba0d909 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Mon, 30 May 2016 15:27:13 +0200 Subject: [PATCH] Turn CuraApplication::_onExit into public api as saveSettings Since we need it for the autosave plugin Contributes to CURA-1615 --- cura/CuraApplication.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index f0610a3538..eccb3e4525 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -116,6 +116,7 @@ class CuraApplication(QtApplication): self._center_after_select = False self._camera_animation = None self._cura_actions = None + self._started = False self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity) self.getController().toolOperationStopped.connect(self._onToolOperationStopped) @@ -189,7 +190,7 @@ class CuraApplication(QtApplication): JobQueue.getInstance().jobFinished.connect(self._onJobFinished) - self.applicationShuttingDown.connect(self._onExit) + self.applicationShuttingDown.connect(self.saveSettings) self._recent_files = [] files = Preferences.getInstance().getValue("cura/recent_files").split(";") @@ -199,8 +200,13 @@ class CuraApplication(QtApplication): self._recent_files.append(QUrl.fromLocalFile(f)) - ## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently. - def _onExit(self): + ## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently. + # + # Note that the AutoSave plugin also calls this method. + def saveSettings(self): + if not self._started: # Do not do saving during application start + return + for instance in ContainerRegistry.getInstance().findInstanceContainers(): if not instance.isDirty(): continue @@ -332,6 +338,8 @@ class CuraApplication(QtApplication): for file_name in self._open_file_queue: #Open all the files that were queued up while plug-ins were loading. self._openFile(file_name) + self._started = True + self.exec_() ## Handle Qt events