mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Only check changed settings (and whatever it affects) for errors in POS
CURA-7329
This commit is contained in:
parent
52f01a71c3
commit
28b8ba3748
1 changed files with 25 additions and 11 deletions
|
@ -13,6 +13,8 @@ from UM.Job import Job
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from UM.Settings.ContainerStack import ContainerStack #For typing.
|
from UM.Settings.ContainerStack import ContainerStack #For typing.
|
||||||
|
from UM.Settings.InstanceContainer import InstanceContainer
|
||||||
|
from UM.Settings.SettingDefinition import SettingDefinition
|
||||||
from UM.Settings.SettingRelation import SettingRelation #For typing.
|
from UM.Settings.SettingRelation import SettingRelation #For typing.
|
||||||
|
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
|
@ -103,20 +105,33 @@ class StartSliceJob(Job):
|
||||||
## Check if a stack has any errors.
|
## Check if a stack has any errors.
|
||||||
## returns true if it has errors, false otherwise.
|
## returns true if it has errors, false otherwise.
|
||||||
def _checkStackForErrors(self, stack: ContainerStack) -> bool:
|
def _checkStackForErrors(self, stack: ContainerStack) -> bool:
|
||||||
if stack is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# if there are no per-object settings we don't need to check the other settings here
|
top_of_stack = cast(InstanceContainer, stack.getTop()) # Cache for efficiency.
|
||||||
stack_top = stack.getTop()
|
changed_setting_keys = top_of_stack.getAllKeys()
|
||||||
if stack_top is None or not stack_top.getAllKeys():
|
|
||||||
return False
|
|
||||||
|
|
||||||
for key in stack.getAllKeys():
|
# Add all relations to changed settings as well.
|
||||||
validation_state = stack.getProperty(key, "validationState")
|
for key in top_of_stack.getAllKeys():
|
||||||
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError, ValidatorState.Invalid):
|
instance = top_of_stack.getInstance(key)
|
||||||
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
if instance is None:
|
||||||
|
continue
|
||||||
|
self._addRelations(changed_setting_keys, instance.definition.relations)
|
||||||
|
Job.yieldThread()
|
||||||
|
|
||||||
|
for changed_setting_key in changed_setting_keys:
|
||||||
|
validation_state = stack.getProperty(changed_setting_key, "validationState")
|
||||||
|
|
||||||
|
if validation_state is None:
|
||||||
|
definition = cast(SettingDefinition, stack.getSettingDefinition(changed_setting_key))
|
||||||
|
validator_type = SettingDefinition.getValidatorForType(definition.type)
|
||||||
|
if validator_type:
|
||||||
|
validator = validator_type(changed_setting_key)
|
||||||
|
validation_state = validator(stack)
|
||||||
|
if validation_state in (
|
||||||
|
ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError, ValidatorState.Invalid):
|
||||||
|
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", changed_setting_key, validation_state)
|
||||||
return True
|
return True
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## Runs the job that initiates the slicing.
|
## Runs the job that initiates the slicing.
|
||||||
|
@ -511,4 +526,3 @@ class StartSliceJob(Job):
|
||||||
|
|
||||||
relations_set.add(relation.target.key)
|
relations_set.add(relation.target.key)
|
||||||
self._addRelations(relations_set, relation.target.relations)
|
self._addRelations(relations_set, relation.target.relations)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue