Prevent slicing if there is an invalid setting value

E.g. higher than maximum_value. This seems to work okay but is largely untested because switching to advanced mode gives a segfault.

Contributes to issues CURA-1278 and CURA-1588.
This commit is contained in:
Ghostkeeper 2016-05-23 23:47:38 +02:00
parent b6aa78cc8d
commit 1cbb3a3f28
No known key found for this signature in database
GPG Key ID: 701948C5954A7385

View File

@ -11,6 +11,7 @@ from UM.Qt.Bindings.BackendProxy import BackendState #To determine the state of
from UM.Message import Message from UM.Message import Message
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from UM.Resources import Resources from UM.Resources import Resources
from UM.Settings.Validator import ValidatorState #To find if a setting is in an error state. We can't slice then.
from cura.OneAtATimeIterator import OneAtATimeIterator from cura.OneAtATimeIterator import OneAtATimeIterator
from . import ProcessSlicedLayersJob from . import ProcessSlicedLayersJob
@ -127,15 +128,26 @@ class CuraEngineBackend(Backend):
self._process_layers_job.abort() self._process_layers_job.abort()
self._process_layers_job = None self._process_layers_job = None
#TODO: Re-add don't slice with error stuff. #Don't slice if there is a setting with an error value.
#if self._profile.hasErrorValue(): stack = Application.getInstance().getGlobalContainerStack()
# Logger.log("w", "Profile has error values. Aborting slicing") for key in stack.getAllKeys():
# if self._message: validation_state = stack.getProperty(key, "validationState")
# self._message.hide() #Only setting instances have a validation state, so settings which
# self._message = None #are not overwritten by any instance will have none. The property
# self._message = Message(catalog.i18nc("@info:status", "Unable to slice. Please check your setting values for errors.")) #then, and only then, evaluates to None. We make the assumption that
# self._message.show() #the definition defines the setting with a default value that is
# return #No slicing if we have error values since those are by definition illegal values. #valid. Therefore we can allow both ValidatorState.Valid and None as
#allowable validation states.
#TODO: This assumption is wrong! If the definition defines an inheritance function that through inheritance evaluates to a disallowed value, a setting is still invalid even though it's default!
#TODO: Therefore we must also validate setting definitions.
if validation_state != None and validation_state != ValidatorState.Valid:
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
if self._message: #Hide any old message before creating a new one.
self._message.hide()
self._message = None
self._message = Message(catalog.i18nc("@info:status", "Unable to slice. Please check your setting values for errors."))
self._message.show()
return
self.processingProgress.emit(0.0) self.processingProgress.emit(0.0)
self.backendStateChange.emit(BackendState.NOT_STARTED) self.backendStateChange.emit(BackendState.NOT_STARTED)