From adfd6d40b94a97921eea491a8e7fa0bfe6300fd0 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 3 Jun 2020 22:47:29 +0300 Subject: [PATCH] - made sure that if the user closes the app with an editor open, before the exit the editor is closed and signals disconnected --- CHANGELOG.md | 1 + appEditors/FlatCAMGrbEditor.py | 1 - app_Main.py | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0a5b8f..9919199e 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/appEditors/FlatCAMGrbEditor.py b/appEditors/FlatCAMGrbEditor.py index 7efd9d75..d0907371 100644 --- a/appEditors/FlatCAMGrbEditor.py +++ b/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) diff --git a/app_Main.py b/app_Main.py index aeb372a2..7220fd9d 100644 --- a/app_Main.py +++ b/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