Parcourir la source

- remade visibility threaded
- reimplemented the thread listening for new FlatCAM process starting with args so it is no longer subclassed but using the moveToThread function

Marius Stanciu il y a 6 ans
Parent
commit
a138c539e4
5 fichiers modifiés avec 26 ajouts et 7 suppressions
  1. 18 4
      FlatCAMApp.py
  2. 1 1
      FlatCAMObj.py
  3. 1 1
      FlatCAMWorkerStack.py
  4. 5 0
      README.md
  5. 1 1
      flatcamGUI/GUIElements.py

+ 18 - 4
FlatCAMApp.py

@@ -216,9 +216,15 @@ class App(QtCore.QObject):
             # #########################################################################
             # 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.start(priority=QtCore.QThread.IdlePriority)
             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':
@@ -2029,8 +2035,8 @@ class App(QtCore.QObject):
         self.shell.setWindowIcon(self.ui.app_icon)
         self.shell.setWindowTitle("FlatCAM Shell")
         self.shell.resize(*self.defaults["global_shell_shape"])
-        self.shell.append_output("FlatCAM %s (c)2014-2019 Juan Pablo Caram " % self.version)
-        self.shell.append_output(_("(Type help to get started)\n\n"))
+        self.shell.append_output("FlatCAM %s - " % self.version)
+        self.shell.append_output(_("Type help to get started\n\n"))
 
         self.init_tcl()
 
@@ -9639,14 +9645,19 @@ The normal flow when working in FlatCAM is the following:</span></p>
         obj.to_form()  # Update UI
 
 
-class ArgsThread(QtCore.QThread):
+class ArgsThread(QtCore.QObject):
     open_signal = pyqtSignal(list)
+    start = pyqtSignal()
 
     if sys.platform == 'win32':
         address = (r'\\.\pipe\NPtest', 'AF_PIPE')
     else:
         address = ('/tmp/testipc', 'AF_UNIX')
 
+    def __init__(self):
+        super(ArgsThread, self).__init__()
+        self.start.connect(self.run)
+
     def my_loop(self, address):
         try:
             listener = Listener(*address)
@@ -9669,6 +9680,9 @@ class ArgsThread(QtCore.QThread):
             self.open_signal.emit(msg)
         conn.close()
 
+    # the decorator is a must; without it this technique will not work unless the start signal is connected
+    # in the main thread (where this class is instantiated) after the instance is moved o the new thread
+    @pyqtSlot()
     def run(self):
         self.my_loop(self.address)
 

+ 1 - 1
FlatCAMObj.py

@@ -344,7 +344,7 @@ class FlatCAMObj(QtCore.QObject):
         return self.shapes.visible
 
     @visible.setter
-    def visible(self, value, threaded=False):
+    def visible(self, value, threaded=True):
         log.debug("FlatCAMObj.visible()")
 
         def worker_task(app_obj):

+ 1 - 1
FlatCAMWorkerStack.py

@@ -25,7 +25,7 @@ class WorkerStack(QtCore.QObject):
             thread.started.connect(worker.run)
             worker.task_completed.connect(self.on_task_completed)
 
-            thread.start(QtCore.QThread.NormalPriority)
+            thread.start(QtCore.QThread.HighPriority)
 
             self.workers.append(worker)
             self.threads.append(thread)

+ 5 - 0
README.md

@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
+6.09.2019
+
+- remade visibility threaded
+- reimplemented the thread listening for new FlatCAM process starting with args so it is no longer subclassed but using the moveToThread function
+
 5.09.2019
 
 - fixed issue with loading files at start-up

+ 1 - 1
flatcamGUI/GUIElements.py

@@ -1743,7 +1743,7 @@ class _BrowserTextEdit(QTextEdit):
 
     def clear(self):
         QTextEdit.clear(self)
-        text = "FlatCAM %s (c)2014-2019 Juan Pablo Caram (Type help to get started)\n\n" % self.version
+        text = "FlatCAM %s - Type help to get started\n\n" % self.version
         text = html.escape(text)
         text = text.replace('\n', '<br/>')
         self.moveCursor(QTextCursor.End)