mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Bit of code refactoring to prevent duplication
CURA-1288
This commit is contained in:
parent
184247ced6
commit
95a0c69662
1 changed files with 20 additions and 18 deletions
|
@ -51,6 +51,20 @@ class StartSliceJob(Job):
|
|||
def getSliceMessage(self):
|
||||
return self._slice_message
|
||||
|
||||
## Check if a stack has any errors.
|
||||
## returns true if it has errors, false otherwise.
|
||||
def _checkStackForErrors(self, stack):
|
||||
if stack is None:
|
||||
return False
|
||||
|
||||
for key in stack.getAllKeys():
|
||||
validation_state = stack.getProperty(key, "validationState")
|
||||
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError):
|
||||
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
||||
return True
|
||||
Job.yieldThread()
|
||||
return False
|
||||
|
||||
## Runs the job that initiates the slicing.
|
||||
def run(self):
|
||||
stack = Application.getInstance().getGlobalContainerStack()
|
||||
|
@ -59,30 +73,18 @@ class StartSliceJob(Job):
|
|||
return
|
||||
|
||||
# Don't slice if there is a setting with an error value.
|
||||
for key in stack.getAllKeys():
|
||||
validation_state = stack.getProperty(key, "validationState")
|
||||
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError):
|
||||
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
||||
self.setResult(StartJobResult.SettingError)
|
||||
return
|
||||
|
||||
Job.yieldThread()
|
||||
if self._checkStackForErrors(stack):
|
||||
self.setResult(StartJobResult.SettingError)
|
||||
return
|
||||
|
||||
# Don't slice if there is a per object setting with an error value.
|
||||
for node in DepthFirstIterator(self._scene.getRoot()):
|
||||
if type(node) is not SceneNode or not node.isSelectable():
|
||||
continue
|
||||
|
||||
node_stack = node.callDecoration("getStack")
|
||||
if node_stack:
|
||||
for key in node_stack.getAllKeys():
|
||||
validation_state = node_stack.getProperty(key, "validationState")
|
||||
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError):
|
||||
Logger.log("w", "Per object setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
||||
self.setResult(StartJobResult.SettingError)
|
||||
return
|
||||
|
||||
Job.yieldThread()
|
||||
if self._checkStackForErrors(node.callDecoration("getStack")):
|
||||
self.setResult(StartJobResult.SettingError)
|
||||
return
|
||||
|
||||
with self._scene.getSceneLock():
|
||||
# Remove old layer data.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue