Fix actions relying on never-updating property

CURA-12811
This commit is contained in:
Erwan MATHIEU 2025-10-22 15:50:40 +02:00
parent 5d53f34bf0
commit f19cc66ddb
6 changed files with 9 additions and 42 deletions

View file

@ -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")

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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...")
}

View file

@ -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: