From 24260b29b4c2652ca5a732e9c1462bc7ecc57a9c Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 19 Jan 2020 17:09:41 +0200 Subject: [PATCH 1/2] - fixed some bugs that are visible in Linux regarding the ArgsThread class: on app close we need to quit the QThread running the ArgsThread class and also close the opened Socket --- FlatCAMApp.py | 8 ++++++++ README.md | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index dce2111f..1c843738 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -2681,6 +2681,9 @@ class App(QtCore.QObject): from flatcamGUI.PlotCanvasLegacy import ShapeCollectionLegacy self.tool_shapes = ShapeCollectionLegacy(obj=self, app=self, name="tool") + # used in the delayed shutdown self.start_delayed_quit() method + self.save_timer = None + # ############################################################################### # ################# ADDING FlatCAM EDITORS section ############################## # ############################################################################### @@ -5200,6 +5203,7 @@ class App(QtCore.QObject): del stgs log.debug("App.final_save() --> App UI state saved.") + self.th.quit() self.close_app_signal.emit() def kill_app(self): @@ -12654,6 +12658,10 @@ class ArgsThread(QtCore.QObject): conn.send('close') # close the current instance only if there are args if len(sys.argv) > 1: + try: + listener.close() + except Exception: + pass sys.exit() def serve(self, conn): diff --git a/README.md b/README.md index 2c446e8a..e99020bc 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +19.01.2020 + +- fixed some bugs that are visible in Linux regarding the ArgsThread class: on app close we need to quit the QThread running the ArgsThread class and also close the opened Socket + 15.01.2020 - added key shortcuts and toolbar icons for the new tools: Align Object Tool (ALT+A) and Extract Drills (ALT+I) From a9d69a57fe829130bf64b83e2a81fcada979afee Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 19 Jan 2020 17:39:32 +0200 Subject: [PATCH 2/2] - make sure that the fixes above apply when rebooting app for theme change or for language change --- FlatCAMApp.py | 23 +++++++++++++++++++---- FlatCAMTranslation.py | 6 ++++++ README.md | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 1c843738..63924a09 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -5203,7 +5203,20 @@ class App(QtCore.QObject): del stgs log.debug("App.final_save() --> App UI state saved.") - self.th.quit() + + # try to quit the QThread that run ArgsThread class + try: + self.th.quit() + except Exception: + pass + + # try to quit the Socket opened by ArgsThread class + try: + self.new_launch.listener.close() + except Exception: + pass + + # quit app by signalling for self.kill_app() method self.close_app_signal.emit() def kill_app(self): @@ -12644,13 +12657,15 @@ class ArgsThread(QtCore.QObject): def __init__(self): super(ArgsThread, self).__init__() + self.listener = None + self.start.connect(self.run) def my_loop(self, address): try: - listener = Listener(*address) + self.listener = Listener(*address) while True: - conn = listener.accept() + conn = self.listener.accept() self.serve(conn) except socket.error: conn = Client(*address) @@ -12659,7 +12674,7 @@ class ArgsThread(QtCore.QObject): # close the current instance only if there are args if len(sys.argv) > 1: try: - listener.close() + self.listener.close() except Exception: pass sys.exit() diff --git a/FlatCAMTranslation.py b/FlatCAMTranslation.py index 7db184d9..f7e75d96 100644 --- a/FlatCAMTranslation.py +++ b/FlatCAMTranslation.py @@ -183,6 +183,12 @@ def restart_program(app, ask=None): else: resource_loc = 'share' + # close the Socket in ArgsThread class + app.new_launch.listener.close() + + # close the QThread that runs ArgsThread class + app.th.quit() + if app.should_we_save and app.collection.get_list() or ask is True: msgbox = QtWidgets.QMessageBox() msgbox.setText(_("There are files/objects modified in FlatCAM. " diff --git a/README.md b/README.md index e99020bc..b49bd5e4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing. 19.01.2020 - fixed some bugs that are visible in Linux regarding the ArgsThread class: on app close we need to quit the QThread running the ArgsThread class and also close the opened Socket +- make sure that the fixes above apply when rebooting app for theme change or for language change 15.01.2020