mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 01:07:52 -06:00
The 3mf workspace reader no longer locks application if it is accedently called from main
CURA-1263
This commit is contained in:
parent
60d2d0d092
commit
fa174763cf
2 changed files with 15 additions and 4 deletions
|
@ -113,7 +113,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
self._dialog.setQualityChangesConflict(quality_changes_conflict)
|
self._dialog.setQualityChangesConflict(quality_changes_conflict)
|
||||||
self._dialog.setMaterialConflict(material_conflict)
|
self._dialog.setMaterialConflict(material_conflict)
|
||||||
self._dialog.show()
|
self._dialog.show()
|
||||||
|
|
||||||
|
# Block until the dialog is closed.
|
||||||
self._dialog.waitForClose()
|
self._dialog.waitForClose()
|
||||||
|
|
||||||
if self._dialog.getResult() == {}:
|
if self._dialog.getResult() == {}:
|
||||||
return WorkspaceReader.PreReadResult.cancelled
|
return WorkspaceReader.PreReadResult.cancelled
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from PyQt5.QtCore import Qt, QUrl, pyqtSignal, pyqtSlot, QObject, pyqtProperty
|
from PyQt5.QtCore import Qt, QUrl, pyqtSignal, pyqtSlot, QObject, pyqtProperty, QCoreApplication
|
||||||
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
@ -6,6 +6,7 @@ from UM.Logger import Logger
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
class WorkspaceDialog(QObject):
|
class WorkspaceDialog(QObject):
|
||||||
showDialogSignal = pyqtSignal()
|
showDialogSignal = pyqtSignal()
|
||||||
|
@ -82,7 +83,8 @@ class WorkspaceDialog(QObject):
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
# Emit signal so the right thread actually shows the view.
|
# Emit signal so the right thread actually shows the view.
|
||||||
self._lock.acquire()
|
if threading.current_thread() != threading.main_thread():
|
||||||
|
self._lock.acquire()
|
||||||
# Reset the result
|
# Reset the result
|
||||||
self._result = {"machine": self._default_strategy,
|
self._result = {"machine": self._default_strategy,
|
||||||
"quality_changes": self._default_strategy,
|
"quality_changes": self._default_strategy,
|
||||||
|
@ -116,8 +118,14 @@ class WorkspaceDialog(QObject):
|
||||||
## Block thread until the dialog is closed.
|
## Block thread until the dialog is closed.
|
||||||
def waitForClose(self):
|
def waitForClose(self):
|
||||||
if self._visible:
|
if self._visible:
|
||||||
self._lock.acquire()
|
if threading.current_thread() != threading.main_thread():
|
||||||
self._lock.release()
|
self._lock.acquire()
|
||||||
|
self._lock.release()
|
||||||
|
else:
|
||||||
|
# If this is not run from a separate thread, we need to ensure that the events are still processed.
|
||||||
|
while self._visible:
|
||||||
|
time.sleep(1 / 50)
|
||||||
|
QCoreApplication.processEvents() # Ensure that the GUI does not freeze.
|
||||||
|
|
||||||
def __show(self):
|
def __show(self):
|
||||||
if self._view is None:
|
if self._view is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue