Make sure that project writer runs on Qt thread

CURA-5229

 - Move @call_on_qt_thread to a separate module
 - Make sure that project writer runs on Qt thread because itself and the
   calls it makes can create new QObjects such as InstanceContainers, and
   this must happen on the Qt thread.
This commit is contained in:
Lipu Fei 2018-04-16 15:32:10 +02:00
parent 58e18ded18
commit 62521e93db
3 changed files with 38 additions and 33 deletions

View file

@ -6,16 +6,18 @@ from io import StringIO
import zipfile
from UM.Application import Application
from UM.Logger import Logger
from UM.Preferences import Preferences
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Workspace.WorkspaceWriter import WorkspaceWriter
from cura.Utils.Threading import call_on_qt_thread
class ThreeMFWorkspaceWriter(WorkspaceWriter):
def __init__(self):
super().__init__()
@call_on_qt_thread
def write(self, stream, nodes, mode=WorkspaceWriter.OutputMode.BinaryMode):
application = Application.getInstance()
machine_manager = application.getMachineManager()