From f19cc66ddb9fc5d5224e73e4078b1f127be5dfd3 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 22 Oct 2025 15:50:40 +0200 Subject: [PATCH] Fix actions relying on never-updating property CURA-12811 --- cura/CuraApplication.py | 1 + cura/Machines/MachineErrorChecker.py | 1 - cura/Settings/MachineManager.py | 37 +++------------------- plugins/CuraEngineBackend/StartSliceJob.py | 6 +--- resources/qml/Actions.qml | 4 +-- resources/qml/Preferences/ProfilesPage.qml | 2 +- 6 files changed, 9 insertions(+), 42 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 57d4773cb3..a3ccb7b1a0 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1300,6 +1300,7 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(CuraSceneController, "Cura", 1, 0, self.getCuraSceneController, "SceneController") qmlRegisterSingletonType(ExtruderManager, "Cura", 1, 0, self.getExtruderManager, "ExtruderManager") qmlRegisterSingletonType(MachineManager, "Cura", 1, 0, self.getMachineManager, "MachineManager") + qmlRegisterSingletonType(MachineErrorChecker, "Cura", 1, 0, self.getMachineErrorChecker, "MachineErrorChecker") qmlRegisterSingletonType(IntentManager, "Cura", 1, 6, self.getIntentManager, "IntentManager") qmlRegisterSingletonType(SettingInheritanceManager, "Cura", 1, 0, self.getSettingInheritanceManager, "SettingInheritanceManager") qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 0, self.getSimpleModeSettingsManagerWrapper, "SimpleModeSettingsManager") diff --git a/cura/Machines/MachineErrorChecker.py b/cura/Machines/MachineErrorChecker.py index 87d50e46d4..49b537a8f6 100644 --- a/cura/Machines/MachineErrorChecker.py +++ b/cura/Machines/MachineErrorChecker.py @@ -212,7 +212,6 @@ class MachineErrorChecker(QObject): if result != self._has_errors: self._has_errors = result self.hasErrorUpdated.emit() - self._machine_manager.stacksValidationChanged.emit() self._keys_to_check = keys_to_recheck if keys_to_recheck else set() self._need_to_check = False self._check_in_progress = False diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 3a2201449d..514d534e18 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -9,6 +9,7 @@ from typing import Any, List, Dict, TYPE_CHECKING, Optional, cast, Set from PyQt6.QtCore import QObject, pyqtProperty, pyqtSignal, QTimer from UM.ConfigurationErrorMessage import ConfigurationErrorMessage +from UM.Decorators import deprecated from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Settings.InstanceContainer import InstanceContainer from UM.Settings.Interfaces import ContainerInterface @@ -87,8 +88,6 @@ class MachineManager(QObject): self.globalContainerChanged.connect(self.activeQualityChangesGroupChanged) self.globalContainerChanged.connect(self.activeQualityGroupChanged) - self._stacks_have_errors = None # type: Optional[bool] - extruder_manager = self._application.getExtruderManager() extruder_manager.activeExtruderChanged.connect(self._onActiveExtruderStackChanged) @@ -447,31 +446,6 @@ class MachineManager(QObject): return False return True - def _checkStacksHaveErrors(self) -> bool: - time_start = time.time() - if self._global_container_stack is None: #No active machine. - return False - - if self._global_container_stack.hasErrors(): - Logger.log("d", "Checking global stack for errors took %0.2f s and we found an error" % (time.time() - time_start)) - return True - - # Not a very pretty solution, but the extruder manager doesn't really know how many extruders there are - machine_extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value") - extruder_stacks = self._global_container_stack.extruderList - count = 1 # We start with the global stack - for stack in extruder_stacks: - md = stack.getMetaData() - if "position" in md and int(md["position"]) >= machine_extruder_count: - continue - count += 1 - if stack.hasErrors(): - Logger.log("d", "Checking %s stacks for errors took %.2f s and we found an error in stack [%s]" % (count, time.time() - time_start, str(stack))) - return True - - Logger.log("d", "Checking %s stacks for errors took %.2f s" % (count, time.time() - time_start)) - return False - @pyqtProperty(bool, notify = numUserSettingsChanged) def hasUserSettings(self) -> bool: return self._num_user_settings != 0 @@ -515,13 +489,10 @@ class MachineManager(QObject): container.sendPostponedEmits() @pyqtProperty(bool, notify = stacksValidationChanged) + @deprecated("This property was already inactive and will now be removed, use MachineErrorChecker.hasError instead.", since="5.11.0") def stacksHaveErrors(self) -> bool: - """Check if none of the stacks contain error states - - Note that the _stacks_have_errors is cached due to performance issues - Calling _checkStack(s)ForErrors on every change is simply too expensive - """ - return bool(self._stacks_have_errors) + """Check if none of the stacks contain error states""" + return False @pyqtProperty(str, notify = globalContainerChanged) def activeMachineFirmwareVersion(self) -> str: diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index f303c612f6..7c2183c5a0 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -296,11 +296,6 @@ class StartSliceJob(Job): self.setResult(StartJobResult.Error) return - # Don't slice if there is a setting with an error value. - if CuraApplication.getInstance().getMachineManager().stacksHaveErrors: - self.setResult(StartJobResult.SettingError) - return - if CuraApplication.getInstance().getBuildVolume().hasErrors(): self.setResult(StartJobResult.BuildPlateError) return @@ -309,6 +304,7 @@ class StartSliceJob(Job): while CuraApplication.getInstance().getMachineErrorChecker().needToWaitForResult: time.sleep(0.1) + # Don't slice if there is a setting with an error value. if CuraApplication.getInstance().getMachineErrorChecker().hasError: self.setResult(StartJobResult.SettingError) return diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 1ae0802be7..82fa80b79b 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -232,7 +232,7 @@ Item Action { id: updateProfileAction - enabled: !Cura.MachineManager.stacksHaveErrors && Cura.MachineManager.hasUserSettings && Cura.MachineManager.activeQualityChangesGroup != null + enabled: !Cura.MachineErrorChecker.hasError && Cura.MachineManager.hasUserSettings && Cura.MachineManager.activeQualityChangesGroup != null text: catalog.i18nc("@action:inmenu menubar:profile", "&Update profile with current settings/overrides"); onTriggered: Cura.ContainerManager.updateQualityChanges() } @@ -252,7 +252,7 @@ Item Action { id: addProfileAction - enabled: !Cura.MachineManager.stacksHaveErrors && Cura.MachineManager.hasUserSettings + enabled: !Cura.MachineErrorChecker.hasError && Cura.MachineManager.hasUserSettings text: catalog.i18nc("@action:inmenu menubar:profile", "&Create profile from current settings/overrides...") } diff --git a/resources/qml/Preferences/ProfilesPage.qml b/resources/qml/Preferences/ProfilesPage.qml index b7030f242b..ee9e268315 100644 --- a/resources/qml/Preferences/ProfilesPage.qml +++ b/resources/qml/Preferences/ProfilesPage.qml @@ -93,7 +93,7 @@ UM.ManagementPage id: createMenuButton text: catalog.i18nc("@action:button", "Create new") - enabled: !Cura.MachineManager.stacksHaveErrors + enabled: !Cura.MachineErrorChecker.hasError visible: base.canCreateProfile tooltip: catalog.i18nc("@action:tooltip", "Create new profile from current settings/overrides") onClicked: