From a138c539e4f58cfe27a160424c214b45cfb9bb99 Mon Sep 17 00:00:00 2001
From: Marius Stanciu
Date: Fri, 6 Sep 2019 00:16:33 +0300
Subject: [PATCH] - 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
---
FlatCAMApp.py | 22 ++++++++++++++++++----
FlatCAMObj.py | 2 +-
FlatCAMWorkerStack.py | 2 +-
README.md | 5 +++++
flatcamGUI/GUIElements.py | 2 +-
5 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/FlatCAMApp.py b/FlatCAMApp.py
index 499ab362..e3b9c219 100644
--- a/FlatCAMApp.py
+++ b/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:
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)
diff --git a/FlatCAMObj.py b/FlatCAMObj.py
index 7a85849f..d3c4b253 100644
--- a/FlatCAMObj.py
+++ b/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):
diff --git a/FlatCAMWorkerStack.py b/FlatCAMWorkerStack.py
index 3ce56011..142cd9b1 100644
--- a/FlatCAMWorkerStack.py
+++ b/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)
diff --git a/README.md b/README.md
index 5522cdb2..cdc94b33 100644
--- a/README.md
+++ b/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
diff --git a/flatcamGUI/GUIElements.py b/flatcamGUI/GUIElements.py
index 38f94750..56d3e50f 100644
--- a/flatcamGUI/GUIElements.py
+++ b/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', '
')
self.moveCursor(QTextCursor.End)