Просмотр исходного кода

Merged in Beta (pull request #5)

# Conflicts:
#	README.md
Marius Stanciu 6 лет назад
Родитель
Сommit
f7278a78f7
2 измененных файлов с 31 добавлено и 2 удалено
  1. 25 2
      FlatCAMApp.py
  2. 6 0
      FlatCAMTranslation.py

+ 25 - 2
FlatCAMApp.py

@@ -2694,6 +2694,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 ##############################
         # ###############################################################################
@@ -5213,6 +5216,20 @@ class App(QtCore.QObject):
             del stgs
 
         log.debug("App.final_save() --> App UI state saved.")
+
+        # 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):
@@ -12653,13 +12670,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)
@@ -12667,6 +12686,10 @@ class ArgsThread(QtCore.QObject):
             conn.send('close')
             # close the current instance only if there are args
             if len(sys.argv) > 1:
+                try:
+                    self.listener.close()
+                except Exception:
+                    pass
                 sys.exit()
 
     def serve(self, conn):

+ 6 - 0
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. "