diff options
author | Jelle Spijker <spijker.jelle@gmail.com> | 2022-04-21 10:26:48 +0300 |
---|---|---|
committer | Jelle Spijker <spijker.jelle@gmail.com> | 2022-04-21 10:26:48 +0300 |
commit | 16d0a81911d8610ebc39836dc3c44b73ce0c0a00 (patch) | |
tree | bc4ae17acad281104781e0784e7bdc24ccdecf2f /cura | |
parent | 1b228ecc07d669bd50e6cfac5a35d4e8107fca43 (diff) | |
parent | ffa0106937fb144943785a7a80740d8e2b0fd77a (diff) |
Merge remote-tracking branch 'origin/fix_wait_for_first_slice' into 5.0
Diffstat (limited to 'cura')
-rw-r--r-- | cura/Machines/MachineErrorChecker.py | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/cura/Machines/MachineErrorChecker.py b/cura/Machines/MachineErrorChecker.py index bfefe80fa5..2bc8a6bc58 100644 --- a/cura/Machines/MachineErrorChecker.py +++ b/cura/Machines/MachineErrorChecker.py @@ -53,6 +53,8 @@ class MachineErrorChecker(QObject): self._keys_to_check = set() # type: Set[str] + self._num_keys_to_check_per_update = 10 + def initialize(self) -> None: self._error_check_timer.timeout.connect(self._rescheduleCheck) @@ -162,37 +164,37 @@ class MachineErrorChecker(QObject): self._check_in_progress = True - # If there is nothing to check any more, it means there is no error. - if not self._stacks_and_keys_to_check: - # Finish - self._setResult(False) - return - - # Get the next stack and key to check - stack, key = self._stacks_and_keys_to_check.popleft() - - enabled = stack.getProperty(key, "enabled") - if not enabled: - self._application.callLater(self._checkStack) - return - - validation_state = stack.getProperty(key, "validationState") - if validation_state is None: - # Setting is not validated. This can happen if there is only a setting definition. - # We do need to validate it, because a setting definitions value can be set by a function, which could - # be an invalid setting. - definition = stack.getSettingDefinition(key) - validator_type = SettingDefinition.getValidatorForType(definition.type) - if validator_type: - validator = validator_type(key) - validation_state = validator(stack) - if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError, ValidatorState.Invalid): - # Since we don't know if any of the settings we didn't check is has an error value, store the list for the - # next check. - keys_to_recheck = {setting_key for stack, setting_key in self._stacks_and_keys_to_check} - keys_to_recheck.add(key) - self._setResult(True, keys_to_recheck = keys_to_recheck) - return + for i in range(self._num_keys_to_check_per_update): + # If there is nothing to check any more, it means there is no error. + if not self._stacks_and_keys_to_check: + # Finish + self._setResult(False) + return + + # Get the next stack and key to check + stack, key = self._stacks_and_keys_to_check.popleft() + + enabled = stack.getProperty(key, "enabled") + if not enabled: + continue + + validation_state = stack.getProperty(key, "validationState") + if validation_state is None: + # Setting is not validated. This can happen if there is only a setting definition. + # We do need to validate it, because a setting definitions value can be set by a function, which could + # be an invalid setting. + definition = stack.getSettingDefinition(key) + validator_type = SettingDefinition.getValidatorForType(definition.type) + if validator_type: + validator = validator_type(key) + validation_state = validator(stack) + if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError, ValidatorState.Invalid): + # Since we don't know if any of the settings we didn't check is has an error value, store the list for the + # next check. + keys_to_recheck = {setting_key for stack, setting_key in self._stacks_and_keys_to_check} + keys_to_recheck.add(key) + self._setResult(True, keys_to_recheck = keys_to_recheck) + continue # Schedule the check for the next key self._application.callLater(self._checkStack) |