mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 17:27:51 -06:00
Let the error checker calculate the error values a bit more "on demand"
Previously it would just re-try all settings, but this really isn't needed (since we have a setting relationship object that can tell us what settings depend on what). This won't speed things up in a worst case scenario (since that will still be "caluclate all the settings") but it will speed it up in most cases. Most setting changes now only trigger a calculation that takes <0.2 sec isntead of the 1.1 sec. Yes, those numbers seem big, but the error checking is already built in such a way that it spreads this out over multiple frames (so it's not actually freezing that time, but it is doing shit it shouldn't do!) CURA-7106
This commit is contained in:
parent
90c6183634
commit
ac0c0d0698
1 changed files with 19 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import time
|
||||
|
@ -14,6 +14,7 @@ from UM.Settings.Validator import ValidatorState
|
|||
|
||||
import cura.CuraApplication
|
||||
|
||||
|
||||
class MachineErrorChecker(QObject):
|
||||
"""This class performs setting error checks for the currently active machine.
|
||||
|
||||
|
@ -50,6 +51,8 @@ class MachineErrorChecker(QObject):
|
|||
self._error_check_timer.setInterval(100)
|
||||
self._error_check_timer.setSingleShot(True)
|
||||
|
||||
self._keys_to_check = set()
|
||||
|
||||
def initialize(self) -> None:
|
||||
self._error_check_timer.timeout.connect(self._rescheduleCheck)
|
||||
|
||||
|
@ -103,6 +106,7 @@ class MachineErrorChecker(QObject):
|
|||
|
||||
if property_name != "value":
|
||||
return
|
||||
self._keys_to_check.add(key)
|
||||
self.startErrorCheck()
|
||||
|
||||
def startErrorCheck(self, *args: Any) -> None:
|
||||
|
@ -140,7 +144,10 @@ class MachineErrorChecker(QObject):
|
|||
# Populate the (stack, key) tuples to check
|
||||
self._stacks_and_keys_to_check = deque()
|
||||
for stack in global_stack.extruderList:
|
||||
for key in stack.getAllKeys():
|
||||
if not self._keys_to_check:
|
||||
self._keys_to_check = stack.getAllKeys()
|
||||
|
||||
for key in self._keys_to_check:
|
||||
self._stacks_and_keys_to_check.append((stack, key))
|
||||
|
||||
self._application.callLater(self._checkStack)
|
||||
|
@ -181,18 +188,25 @@ class MachineErrorChecker(QObject):
|
|||
validator = validator_type(key)
|
||||
validation_state = validator(stack)
|
||||
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError, ValidatorState.Invalid):
|
||||
# Finish
|
||||
self._setResult(True)
|
||||
# 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
|
||||
|
||||
# Schedule the check for the next key
|
||||
self._application.callLater(self._checkStack)
|
||||
|
||||
def _setResult(self, result: bool) -> None:
|
||||
def _setResult(self, result: bool, keys_to_recheck = None) -> None:
|
||||
if result != self._has_errors:
|
||||
self._has_errors = result
|
||||
self.hasErrorUpdated.emit()
|
||||
self._machine_manager.stacksValidationChanged.emit()
|
||||
if keys_to_recheck is None:
|
||||
self._keys_to_check = set()
|
||||
else:
|
||||
self._keys_to_check = keys_to_recheck
|
||||
self._need_to_check = False
|
||||
self._check_in_progress = False
|
||||
self.needToWaitForResultChanged.emit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue