From fb598a24445b1229a57647892103b5de85bdd5a9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 10 Feb 2016 13:19:12 +0100 Subject: [PATCH 1/6] Operation stopped no longer cause a re-slice. No idea why this was the case as the result of an operation should decide if a reslice should be triggered (eg; transformation causes scenechanged to be triggered) CURA-829 --- plugins/CuraEngineBackend/CuraEngineBackend.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 27ead0f681..321233e4bf 100644 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -249,7 +249,6 @@ class CuraEngineBackend(Backend): def _onToolOperationStopped(self, tool): self._enabled = True # Tool stop, start listening for changes again. - self._onChanged() def _onActiveViewChanged(self): if Application.getInstance().getController().getActiveView(): From edb7803760f03fecd67ba5b846c6470360ba9cda Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 10 Feb 2016 13:37:37 +0100 Subject: [PATCH 2/6] Make the machine file types filter optional for OutputDevice The call to OutputDevice from the save button filters by the file types available to the machine. The call to OutputDevice from the application menu doesn't. Contributes to issue CURA-611. --- .../RemovableDriveOutputDevice.py | 17 ++++++++--------- resources/qml/Cura.qml | 4 ++-- resources/qml/SaveButton.qml | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py index b18df75bc9..b1d6061848 100644 --- a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py +++ b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py @@ -25,20 +25,19 @@ class RemovableDriveOutputDevice(OutputDevice): self._writing = False - def requestWrite(self, node, file_name = None): + def requestWrite(self, node, file_name = None, filter_by_machine = False): if self._writing: raise OutputDeviceError.DeviceBusyError() file_formats = Application.getInstance().getMeshFileHandler().getSupportedFileTypesWrite() #Formats supported by this application. - machine_file_formats = Application.getInstance().getMachineManager().getActiveMachineInstance().getMachineDefinition().getFileFormats() - for file_format in file_formats: - if file_format["mime_type"] in machine_file_formats: - writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(file_format["mime_type"]) - extension = file_format["extension"] - break #We have a valid mesh writer, supported by the machine. Just pick the first one. - else: - Logger.log("e", "None of the file formats supported by this machine are supported by the application!") + if filter_by_machine: + machine_file_formats = Application.getInstance().getMachineManager().getActiveMachineInstance().getMachineDefinition().getFileFormats() + file_formats = list(filter(lambda file_format: file_format["mime_type"] in machine_file_formats, file_formats)) #Take the intersection between file_formats and machine_file_formats. + if len(file_formats) == 0: + Logger.log("e", "There are no file formats available to write with!") raise OutputDeviceError.WriteRequestFailedError() + writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(file_formats[0]["mime_type"]) #Just take the first file format available. + extension = file_format[0]["extension"] if file_name == None: for n in BreadthFirstIterator(node): diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index d8f2b4d4ad..a1e1ce4909 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -92,7 +92,7 @@ UM.MainWindow text: catalog.i18nc("@action:inmenu menubar:file", "&Save Selection to File"); enabled: UM.Selection.hasSelection; iconName: "document-save-as"; - onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", Printer.jobName); + onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", Printer.jobName, false); } Menu { @@ -108,7 +108,7 @@ UM.MainWindow MenuItem { text: model.description; - onTriggered: UM.OutputDeviceManager.requestWriteToDevice(model.id, Printer.jobName); + onTriggered: UM.OutputDeviceManager.requestWriteToDevice(model.id, Printer.jobName, false); } onObjectAdded: saveAllMenu.insertItem(index, object) onObjectRemoved: saveAllMenu.removeItem(object) diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index ce726afc04..4a29325007 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -84,7 +84,7 @@ Rectangle { text: UM.OutputDeviceManager.activeDeviceShortDescription onClicked: { - UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, Printer.jobName) + UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, Printer.jobName, true) } style: ButtonStyle { From ac25b1bdafca9d88db74d42414ab5320978b7e39 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 10 Feb 2016 13:44:22 +0100 Subject: [PATCH 3/6] Always save everything when the change timer timeouts This prevents issues where certain things were not saved properly Contributes to CURA-511 --- plugins/AutoSave/AutoSave.py | 60 ++++++++++-------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/plugins/AutoSave/AutoSave.py b/plugins/AutoSave/AutoSave.py index b6251addcd..79d91e75b2 100644 --- a/plugins/AutoSave/AutoSave.py +++ b/plugins/AutoSave/AutoSave.py @@ -13,17 +13,17 @@ class AutoSave(Extension): def __init__(self): super().__init__() - Preferences.getInstance().preferenceChanged.connect(self._onPreferenceChanged) + #Preferences.getInstance().preferenceChanged.connect(self._onPreferenceChanged) + Preferences.getInstance().preferenceChanged.connect(self._triggerTimer) machine_manager = Application.getInstance().getMachineManager() self._profile = None machine_manager.activeProfileChanged.connect(self._onActiveProfileChanged) - machine_manager.profileNameChanged.connect(self._onProfileNameChanged) - machine_manager.profilesChanged.connect(self._onProfilesChanged) - machine_manager.machineInstanceNameChanged.connect(self._onInstanceNameChanged) - machine_manager.machineInstancesChanged.connect(self._onInstancesChanged) - Application + machine_manager.profileNameChanged.connect(self._triggerTimer) + machine_manager.profilesChanged.connect(self._triggerTimer) + machine_manager.machineInstanceNameChanged.connect(self._triggerTimer) + machine_manager.machineInstancesChanged.connect(self._triggerTimer) self._onActiveProfileChanged() Preferences.getInstance().addPreference("cura/autosave_delay", 1000 * 10) @@ -33,53 +33,27 @@ class AutoSave(Extension): self._change_timer.setSingleShot(True) self._change_timer.timeout.connect(self._onTimeout) - self._save_preferences = False - self._save_profiles = False - self._save_instances = False + self._saving = False - def _onPreferenceChanged(self, preference): - self._save_preferences = True - self._change_timer.start() - - def _onSettingValueChanged(self, setting): - self._save_profiles = True - self._change_timer.start() + def _triggerTimer(self, *args): + if not self._saving: + self._change_timer.start() def _onActiveProfileChanged(self): if self._profile: - self._profile.settingValueChanged.disconnect(self._onSettingValueChanged) + self._profile.settingValueChanged.disconnect(self._triggerTimer) self._profile = Application.getInstance().getMachineManager().getWorkingProfile() if self._profile: - self._profile.settingValueChanged.connect(self._onSettingValueChanged) - - def _onProfileNameChanged(self, name): - self._onProfilesChanged() - - def _onProfilesChanged(self): - self._save_profiles = True - self._change_timer.start() - - def _onInstanceNameChanged(self, name): - self._onInstancesChanged() - - def _onInstancesChanged(self): - self._save_instances = True - self._change_timer.start() + self._profile.settingValueChanged.connect(self._triggerTimer) def _onTimeout(self): + self._saving = True # To prevent the save process from triggering another autosave. Logger.log("d", "Autosaving preferences, instances and profiles") - if self._save_preferences: - Preferences.getInstance().writeToFile(Resources.getStoragePath(Resources.Preferences, Application.getInstance().getApplicationName() + ".cfg")) + Preferences.getInstance().writeToFile(Resources.getStoragePath(Resources.Preferences, Application.getInstance().getApplicationName() + ".cfg")) + Application.getInstance().getMachineManager().saveMachineInstances() + Application.getInstance().getMachineManager().saveProfiles() - if self._save_instances: - Application.getInstance().getMachineManager().saveMachineInstances() - - if self._save_profiles: - Application.getInstance().getMachineManager().saveProfiles() - - self._save_preferences = False - self._save_instances = False - self._save_profiles = False + self._saving = False From 894624fc2dcd1adc9121b17e7ccc23cb3836ec4a Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 10 Feb 2016 13:47:25 +0100 Subject: [PATCH 4/6] Remove the "Using python impl of Protobuf" warning message Since we now have c++ bindings this has become irrelevant. Contributes to CURA-434 --- cura/CuraApplication.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 996e621c7a..9dba5f6335 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -150,9 +150,6 @@ class CuraApplication(QtApplication): parser.add_argument("--debug", dest="debug-mode", action="store_true", default=False, help="Enable detailed crash reports.") def run(self): - if "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" not in os.environ or os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] != "cpp": - Logger.log("w", "Using Python implementation of Protobuf, expect bad performance!") - self._i18n_catalog = i18nCatalog("cura"); i18nCatalog.setTagReplacements({ From 041fa2b3592e015eebe779169c9d7f4565b3a788 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 10 Feb 2016 13:52:05 +0100 Subject: [PATCH 5/6] Import Arcus before importing Cura (and PyQt5) Workaround an issue on certain Linux systems that causes a race condition between Arcus and PyQt5. Contributes to CURA-434 --- cura_app.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cura_app.py b/cura_app.py index 831582687c..e19147c5e5 100755 --- a/cura_app.py +++ b/cura_app.py @@ -12,15 +12,12 @@ def exceptHook(type, value, traceback): sys.excepthook = exceptHook -try: - from google.protobuf.pyext import _message -except ImportError: - pass -else: - os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "cpp" - -if True: # To make the code style checker stop complaining - import cura.CuraApplication +# Workaround for a race condition on certain systems where there +# is a race condition between Arcus and PyQt. Importing Arcus +# first seems to prevent Sip from going into a state where it +# tries to create PyQt objects on a non-main thread. +import Arcus +import cura.CuraApplication if sys.platform == "win32" and hasattr(sys, "frozen"): import os From 6bcce7ca8eaf37055cdd20b5061507e5a4bc66fd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 10 Feb 2016 15:05:36 +0100 Subject: [PATCH 6/6] Repair saving to removable drive Typo. Sorry. Contributes to issue CURA-611. --- .../RemovableDriveOutputDevice/RemovableDriveOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py index b1d6061848..f73ba46c85 100644 --- a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py +++ b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py @@ -37,7 +37,7 @@ class RemovableDriveOutputDevice(OutputDevice): Logger.log("e", "There are no file formats available to write with!") raise OutputDeviceError.WriteRequestFailedError() writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(file_formats[0]["mime_type"]) #Just take the first file format available. - extension = file_format[0]["extension"] + extension = file_formats[0]["extension"] if file_name == None: for n in BreadthFirstIterator(node):