Browse Source

Turn CuraApplication::_onExit into public api as saveSettings

Since we need it for the autosave plugin

Contributes to CURA-1615
Arjen Hiemstra 8 years ago
parent
commit
bdc8fdf508
1 changed files with 11 additions and 3 deletions
  1. 11 3
      cura/CuraApplication.py

+ 11 - 3
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