diff --git a/CHANGELOG.md b/CHANGELOG.md index fbcc3f4c..75b8e67c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +7.05.2020 + +- added a fix so the app close is now clean, with exit code 0 as set + 6.05.2020 - wip in adding Exclusion areas in Geometry object; each Geometry object has now a storage for shapes (exclusion shapes, should I make them more general?) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index eb4e9569..d845b0c2 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3598,14 +3598,13 @@ class App(QtCore.QObject): # try to quit the Socket opened by ArgsThread class try: - self.new_launch.thread_exit = True - self.new_launch.listener.close() + self.new_launch.stop.emit() except Exception as err: log.debug("App.quit_application() --> %s" % str(err)) # try to quit the QThread that run ArgsThread class try: - self.th.terminate() + self.th.quit() except Exception as e: log.debug("App.quit_application() --> %s" % str(e)) @@ -3615,7 +3614,6 @@ class App(QtCore.QObject): # quit app by signalling for self.kill_app() method # self.close_app_signal.emit() QtWidgets.qApp.quit() - # QtCore.QCoreApplication.exit() # When the main event loop is not started yet in which case the qApp.quit() will do nothing # we use the following command @@ -3627,7 +3625,6 @@ class App(QtCore.QObject): @staticmethod def kill_app(): - # QtCore.QCoreApplication.quit() QtWidgets.qApp.quit() # When the main event loop is not started yet in which case the qApp.quit() will do nothing # we use the following command @@ -10888,6 +10885,7 @@ class App(QtCore.QObject): class ArgsThread(QtCore.QObject): open_signal = pyqtSignal(list) start = pyqtSignal() + stop = pyqtSignal() if sys.platform == 'win32': address = (r'\\.\pipe\NPtest', 'AF_PIPE') @@ -10900,6 +10898,7 @@ class ArgsThread(QtCore.QObject): self.thread_exit = False self.start.connect(self.run) + self.stop.connect(self.close_listener) def my_loop(self, address): try: @@ -10943,4 +10942,9 @@ class ArgsThread(QtCore.QObject): def run(self): self.my_loop(self.address) + @pyqtSlot() + def close_listener(self): + self.thread_exit = True + self.listener.close() + # end of file diff --git a/FlatCAMCommon.py b/FlatCAMCommon.py index c29ac4f3..ab60dccd 100644 --- a/FlatCAMCommon.py +++ b/FlatCAMCommon.py @@ -491,27 +491,3 @@ class ExclusionAreas: FlatCAMTool.delete_moving_selection_shape(self) self.app.delete_selection_shape() FlatCAMTool.delete_tool_selection_shape(self, shapes_storage=self.exclusion_shapes) - - -class InvertHexColor: - """ - Will invert a hex color made out of 3 chars or 6 chars - From here: http://code.activestate.com/recipes/527747-invert-css-hex-colors/ - """ - def __init__(self): - self.p6 = re.compile("#[0-9a-f]{6};", re.IGNORECASE) - self.p3 = re.compile("#[0-9a-f]{3};", re.IGNORECASE) - - def modify(self, original_color=3): - code = {} - l1 = "#;0123456789abcdef" - l2 = "#;fedcba9876543210" - - for i in range(len(l1)): - code[l1[i]] = l2[i] - inverted = "" - - content = p6.sub(modify, content) - content = p3.sub(modify, content) - return inverted - diff --git a/FlatCAMTranslation.py b/FlatCAMTranslation.py index 4e8edbf3..82a8ac33 100644 --- a/FlatCAMTranslation.py +++ b/FlatCAMTranslation.py @@ -186,8 +186,7 @@ def restart_program(app, ask=None): # try to quit the Socket opened by ArgsThread class try: - app.new_launch.thread_exit = True - app.new_launch.listener.close() + app.new_launch.stop.emit() except Exception as err: log.debug("FlatCAMTranslation.restart_program() --> %s" % str(err)) diff --git a/flatcamObjects/FlatCAMGeometry.py b/flatcamObjects/FlatCAMGeometry.py index 1d2bad73..9cfeab20 100644 --- a/flatcamObjects/FlatCAMGeometry.py +++ b/flatcamObjects/FlatCAMGeometry.py @@ -1674,15 +1674,11 @@ class GeometryObject(FlatCAMObj, Geometry): The actual work is done by the target CNCJobObject object's `generate_from_geometry_2()` method. - :param tools_dict: a dictionary that holds the whole data needed to create the Gcode - (including the solid_geometry) - - :param tools_in_use: the tools that are used, needed by some preprocessors - :type list of lists, each list in the list is made out of row elements of tools table from GUI - :param outname: - :param tools_dict: - :param tools_in_use: + :param tools_dict: a dictionary that holds the whole data needed to create the Gcode + (including the solid_geometry) + :param tools_in_use: the tools that are used, needed by some preprocessors + :type tools_in_use list of lists, each list in the list is made out of row elements of tools table from GUI :param segx: number of segments on the X axis, for auto-levelling :param segy: number of segments on the Y axis, for auto-levelling :param plot: if True the generated object will be plotted; if False will not be plotted @@ -1726,7 +1722,7 @@ class GeometryObject(FlatCAMObj, Geometry): # count the tools tool_cnt = 0 - dia_cnc_dict = {} + # dia_cnc_dict = {} # this turn on the FlatCAMCNCJob plot for multiple tools job_obj.multitool = True @@ -1866,7 +1862,7 @@ class GeometryObject(FlatCAMObj, Geometry): # count the tools tool_cnt = 0 - dia_cnc_dict = {} + # dia_cnc_dict = {} # this turn on the FlatCAMCNCJob plot for multiple tools job_obj.multitool = True @@ -2040,7 +2036,7 @@ class GeometryObject(FlatCAMObj, Geometry): use_thread=True, plot=True): """ - Only used for TCL Command. + Only used by the TCL Command Cncjob. Creates a CNCJob out of this Geometry object. The actual work is done by the target camlib.CNCjob `generate_from_geometry_2()` method.