From 1e3947a244dd991ee33c70dfaa5b8d29e8eb65d6 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 31 Dec 2019 02:37:11 +0200 Subject: [PATCH 1/3] - another attempt to make TclCommand quit_flatcam work under Linux - use signal to call a hard exit when in Linux --- FlatCAMApp.py | 16 +++++++++++----- README.md | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index c4d96468..dad1eb59 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -241,6 +241,8 @@ class App(QtCore.QObject): # signal emitted when jumping jump_signal = pyqtSignal(tuple) + hard_exit_signal = pyqtSignal() + def __init__(self, user_defaults=True): """ Starts the application. @@ -2137,6 +2139,8 @@ class App(QtCore.QObject): self.ui.grid_snap_btn.triggered.connect(self.on_grid_snap_triggered) + self.hard_exit_signal.connect(self.on_hard_exit) + # ##################################################################################### # ########### FINISHED CONNECTING SIGNALS ############################################# # ##################################################################################### @@ -3597,7 +3601,7 @@ class App(QtCore.QObject): Handles input from the shell. See FlatCAMApp.setup_shell for shell commands. :param text: Input command - :param reraise: Re-raise TclError exceptions in Python (mostly for unitttests). + :param reraise: Re-raise TclError exceptions in Python (mostly for unittests). :param no_echo: If True it will not try to print to the Shell because most likely the shell is hidden and it will create crashes of the _Expandable_Edit widget :return: Output from the command @@ -3614,6 +3618,7 @@ class App(QtCore.QObject): self.shell.append_output(result + '\n') except tk.TclError as e: + # This will display more precise answer if something in TCL shell fails result = self.tcl.eval("set errorInfo") self.log.error("Exec command Exception: %s" % (result + '\n')) @@ -5142,10 +5147,11 @@ class App(QtCore.QObject): # QtWidgets.qApp.quit() QtCore.QCoreApplication.exit() if sys.platform != 'win32': - try: - sys.exit() - except Exception: - pass + self.hard_exit_signal.emit() + + def on_hard_exit(self): + log.debug("App.on_hard_exit() Executed") + sys.exit() def on_portable_checked(self, state): """ diff --git a/README.md b/README.md index c8d6ada9..a41177b1 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ CAD program, and create G-Code for Isolation routing. - Buffer sub-tool in Transform Tool: added the possibility to apply a factor effectively scaling the aperture size thus the copper features sizes - in Transform Tool adjusted the GUI -- fixed some decimals issues in NCC Tool, Paint Tool and Excellon Editor (they were still using the harcoded values) +- fixed some decimals issues in NCC Tool, Paint Tool and Excellon Editor (they were still using the hardcoded values) - some small updates in the NCC Tool - changes in the Preferences UI for NCC and Paint Tool in Tool Dia entry field - fixed Tcl commands that use the overlap parameter to switch from fraction to percentage @@ -21,6 +21,7 @@ CAD program, and create G-Code for Isolation routing. - attempt to make TclCommand quit_flatcam work under Linux - some fixes in the NCC Tcl command (using the bool() method on some params) - another attempt to make TclCommand quit_flatcam work under Linux +- another attempt to make TclCommand quit_flatcam work under Linux - use signal to call a hard exit when in Linux 29.12.2019 From e245f2839d0d72d7623a82c7f708e3d3bb0bf848 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 31 Dec 2019 03:16:47 +0200 Subject: [PATCH 2/3] - TclCommand quit_flatcam work under Linux --- FlatCAMApp.py | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index dad1eb59..2675b776 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -241,8 +241,6 @@ class App(QtCore.QObject): # signal emitted when jumping jump_signal = pyqtSignal(tuple) - hard_exit_signal = pyqtSignal() - def __init__(self, user_defaults=True): """ Starts the application. @@ -255,6 +253,19 @@ class App(QtCore.QObject): self.main_thread = QtWidgets.QApplication.instance().thread() + # ######################################################################### + # Setup the listening thread for another instance launching with args ##### + # ######################################################################### + + # make sure the thread is stored by using a self. otherwise it's garbage collected + self.th = QtCore.QThread() + self.th.start(priority=QtCore.QThread.LowestPriority) + + self.new_launch = ArgsThread() + self.new_launch.open_signal[list].connect(self.on_startup_args) + self.new_launch.moveToThread(self.th) + self.new_launch.start.emit() + # ############################################################################ # # ################# OS-specific ############################################ # ############################################################################ @@ -262,20 +273,6 @@ class App(QtCore.QObject): # Folder for user settings. if sys.platform == 'win32': - - # ######################################################################### - # Setup the listening thread for another instance launching with args ##### - # ######################################################################### - - # make sure the thread is stored by using a self. otherwise it's garbage collected - self.th = QtCore.QThread() - self.th.start(priority=QtCore.QThread.LowestPriority) - - self.new_launch = ArgsThread() - self.new_launch.open_signal[list].connect(self.on_startup_args) - self.new_launch.moveToThread(self.th) - self.new_launch.start.emit() - from win32com.shell import shell, shellcon if platform.architecture()[0] == '32bit': App.log.debug("Win32!") @@ -2139,8 +2136,6 @@ class App(QtCore.QObject): self.ui.grid_snap_btn.triggered.connect(self.on_grid_snap_triggered) - self.hard_exit_signal.connect(self.on_hard_exit) - # ##################################################################################### # ########### FINISHED CONNECTING SIGNALS ############################################# # ##################################################################################### @@ -5143,15 +5138,7 @@ class App(QtCore.QObject): del stgs log.debug("App.final_save() --> App UI state saved.") - - # QtWidgets.qApp.quit() - QtCore.QCoreApplication.exit() - if sys.platform != 'win32': - self.hard_exit_signal.emit() - - def on_hard_exit(self): - log.debug("App.on_hard_exit() Executed") - sys.exit() + QtWidgets.qApp.quit() def on_portable_checked(self, state): """ From c8955e0a006d5c6b63a664139e0339d40bc4e63d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 31 Dec 2019 03:17:17 +0200 Subject: [PATCH 3/3] - TclCommand quit_flatcam work under Linux --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a41177b1..0d4e5943 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ CAD program, and create G-Code for Isolation routing. - some fixes in the NCC Tcl command (using the bool() method on some params) - another attempt to make TclCommand quit_flatcam work under Linux - another attempt to make TclCommand quit_flatcam work under Linux - use signal to call a hard exit when in Linux +- TclCommand quit_flatcam work under Linux 29.12.2019