Преглед на файлове

- added a fix so the app close is now clean, with exit code 0 as set

Marius Stanciu преди 5 години
родител
ревизия
4ece23c456
променени са 5 файла, в които са добавени 21 реда и са изтрити 42 реда
  1. 4 0
      CHANGELOG.md
  2. 9 5
      FlatCAMApp.py
  3. 0 24
      FlatCAMCommon.py
  4. 1 2
      FlatCAMTranslation.py
  5. 7 11
      flatcamObjects/FlatCAMGeometry.py

+ 4 - 0
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
 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?)
 - 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?)

+ 9 - 5
FlatCAMApp.py

@@ -3598,14 +3598,13 @@ class App(QtCore.QObject):
 
 
         # try to quit the Socket opened by ArgsThread class
         # try to quit the Socket opened by ArgsThread class
         try:
         try:
-            self.new_launch.thread_exit = True
-            self.new_launch.listener.close()
+            self.new_launch.stop.emit()
         except Exception as err:
         except Exception as err:
             log.debug("App.quit_application() --> %s" % str(err))
             log.debug("App.quit_application() --> %s" % str(err))
 
 
         # try to quit the QThread that run ArgsThread class
         # try to quit the QThread that run ArgsThread class
         try:
         try:
-            self.th.terminate()
+            self.th.quit()
         except Exception as e:
         except Exception as e:
             log.debug("App.quit_application() --> %s" % str(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
         # quit app by signalling for self.kill_app() method
         # self.close_app_signal.emit()
         # self.close_app_signal.emit()
         QtWidgets.qApp.quit()
         QtWidgets.qApp.quit()
-        # QtCore.QCoreApplication.exit()
 
 
         # When the main event loop is not started yet in which case the qApp.quit() will do nothing
         # When the main event loop is not started yet in which case the qApp.quit() will do nothing
         # we use the following command
         # we use the following command
@@ -3627,7 +3625,6 @@ class App(QtCore.QObject):
 
 
     @staticmethod
     @staticmethod
     def kill_app():
     def kill_app():
-        # QtCore.QCoreApplication.quit()
         QtWidgets.qApp.quit()
         QtWidgets.qApp.quit()
         # When the main event loop is not started yet in which case the qApp.quit() will do nothing
         # When the main event loop is not started yet in which case the qApp.quit() will do nothing
         # we use the following command
         # we use the following command
@@ -10888,6 +10885,7 @@ class App(QtCore.QObject):
 class ArgsThread(QtCore.QObject):
 class ArgsThread(QtCore.QObject):
     open_signal = pyqtSignal(list)
     open_signal = pyqtSignal(list)
     start = pyqtSignal()
     start = pyqtSignal()
+    stop = pyqtSignal()
 
 
     if sys.platform == 'win32':
     if sys.platform == 'win32':
         address = (r'\\.\pipe\NPtest', 'AF_PIPE')
         address = (r'\\.\pipe\NPtest', 'AF_PIPE')
@@ -10900,6 +10898,7 @@ class ArgsThread(QtCore.QObject):
         self.thread_exit = False
         self.thread_exit = False
 
 
         self.start.connect(self.run)
         self.start.connect(self.run)
+        self.stop.connect(self.close_listener)
 
 
     def my_loop(self, address):
     def my_loop(self, address):
         try:
         try:
@@ -10943,4 +10942,9 @@ class ArgsThread(QtCore.QObject):
     def run(self):
     def run(self):
         self.my_loop(self.address)
         self.my_loop(self.address)
 
 
+    @pyqtSlot()
+    def close_listener(self):
+        self.thread_exit = True
+        self.listener.close()
+
 # end of file
 # end of file

+ 0 - 24
FlatCAMCommon.py

@@ -491,27 +491,3 @@ class ExclusionAreas:
         FlatCAMTool.delete_moving_selection_shape(self)
         FlatCAMTool.delete_moving_selection_shape(self)
         self.app.delete_selection_shape()
         self.app.delete_selection_shape()
         FlatCAMTool.delete_tool_selection_shape(self, shapes_storage=self.exclusion_shapes)
         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
-

+ 1 - 2
FlatCAMTranslation.py

@@ -186,8 +186,7 @@ def restart_program(app, ask=None):
 
 
     # try to quit the Socket opened by ArgsThread class
     # try to quit the Socket opened by ArgsThread class
     try:
     try:
-        app.new_launch.thread_exit = True
-        app.new_launch.listener.close()
+        app.new_launch.stop.emit()
     except Exception as err:
     except Exception as err:
         log.debug("FlatCAMTranslation.restart_program() --> %s" % str(err))
         log.debug("FlatCAMTranslation.restart_program() --> %s" % str(err))
 
 

+ 7 - 11
flatcamObjects/FlatCAMGeometry.py

@@ -1674,15 +1674,11 @@ class GeometryObject(FlatCAMObj, Geometry):
         The actual work is done by the target CNCJobObject object's
         The actual work is done by the target CNCJobObject object's
         `generate_from_geometry_2()` method.
         `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 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 segx:            number of segments on the X axis, for auto-levelling
         :param segy:            number of segments on the Y 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
         :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
             # count the tools
             tool_cnt = 0
             tool_cnt = 0
 
 
-            dia_cnc_dict = {}
+            # dia_cnc_dict = {}
 
 
             # this turn on the FlatCAMCNCJob plot for multiple tools
             # this turn on the FlatCAMCNCJob plot for multiple tools
             job_obj.multitool = True
             job_obj.multitool = True
@@ -1866,7 +1862,7 @@ class GeometryObject(FlatCAMObj, Geometry):
             # count the tools
             # count the tools
             tool_cnt = 0
             tool_cnt = 0
 
 
-            dia_cnc_dict = {}
+            # dia_cnc_dict = {}
 
 
             # this turn on the FlatCAMCNCJob plot for multiple tools
             # this turn on the FlatCAMCNCJob plot for multiple tools
             job_obj.multitool = True
             job_obj.multitool = True
@@ -2040,7 +2036,7 @@ class GeometryObject(FlatCAMObj, Geometry):
             use_thread=True,
             use_thread=True,
             plot=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
         Creates a CNCJob out of this Geometry object. The actual
         work is done by the target camlib.CNCjob
         work is done by the target camlib.CNCjob
         `generate_from_geometry_2()` method.
         `generate_from_geometry_2()` method.