Browse Source

- made sure that if the user closes the app with an editor open, before the exit the editor is closed and signals disconnected

Marius Stanciu 5 years ago
parent
commit
adfd6d40b9
3 changed files with 28 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 0 1
      appEditors/FlatCAMGrbEditor.py
  3. 27 0
      app_Main.py

+ 1 - 0
CHANGELOG.md

@@ -20,6 +20,7 @@ CHANGELOG for FlatCAM beta
 - fixed the preferences not being saved to a file when the Save button is pressed in Edit -> Preferences
 - fixed and updated the Transform Tools in the Editors
 - updated the language translation strings (and Google_Translated some of them)
+- made sure that if the user closes the app with an editor open, before the exit the editor is closed and signals disconnected
 
 2.06.2020
 

+ 0 - 1
appEditors/FlatCAMGrbEditor.py

@@ -3739,7 +3739,6 @@ class FlatCAMGrbEditor(QtCore.QObject):
         self.disconnect_canvas_event_handlers()
         self.app.ui.grb_edit_toolbar.setDisabled(True)
 
-        settings = QSettings("Open Source", "FlatCAM")
         self.app.ui.corner_snap_btn.setVisible(False)
         self.app.ui.snap_magnet.setVisible(False)
 

+ 27 - 0
app_Main.py

@@ -3191,6 +3191,32 @@ class App(QtCore.QObject):
 
         :return: None
         """
+
+        # close editors before quiting the app, if they are open
+        if self.geo_editor.editor_active is True:
+            self.geo_editor.deactivate()
+            try:
+                self.geo_editor.disconnect()
+            except TypeError:
+                pass
+            log.debug("App.quit_application() --> Geo Editor deactivated.")
+
+        if self.exc_editor.editor_active is True:
+            self.exc_editor.deactivate()
+            try:
+                self.grb_editor.disconnect()
+            except TypeError:
+                pass
+            log.debug("App.quit_application() --> Excellon Editor deactivated.")
+
+        if self.grb_editor.editor_active is True:
+            self.grb_editor.deactivate_grb_editor()
+            try:
+                self.exc_editor.disconnect()
+            except TypeError:
+                pass
+            log.debug("App.quit_application() --> Gerber Editor deactivated.")
+
         self.preferencesUiManager.save_defaults(silent=True)
         log.debug("App.quit_application() --> App Defaults saved.")
 
@@ -3249,6 +3275,7 @@ class App(QtCore.QObject):
         # quit app by signalling for self.kill_app() method
         # self.close_app_signal.emit()
         QtWidgets.qApp.quit()
+        # QtCore.QCoreApplication.quit()
 
         # When the main event loop is not started yet in which case the qApp.quit() will do nothing
         # we use the following command