mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Reduce nesting complexity with some pre-checks
There were two pre-checks here, where the main body of the function was indented two deep. Instead, just early-out if the checks fail. This is easier to read and understand. Found during investigation of CURA-8128.
This commit is contained in:
parent
cc6a629d92
commit
31106d13d0
1 changed files with 31 additions and 29 deletions
|
@ -73,9 +73,13 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand
|
|||
|
||||
# Add all instances that are not added, but are in visibility list
|
||||
for item in visible:
|
||||
if settings.getInstance(item) is None: # Setting was not added already.
|
||||
if settings.getInstance(item) is not None: # Setting was added already.
|
||||
continue
|
||||
definition = self._stack.getSettingDefinition(item)
|
||||
if definition:
|
||||
if not definition:
|
||||
Logger.log("w", f"Unable to add instance ({item}) to per-object visibility because we couldn't find the matching definition.")
|
||||
continue
|
||||
|
||||
new_instance = SettingInstance(definition, settings)
|
||||
stack_nr = -1
|
||||
stack = None
|
||||
|
@ -103,8 +107,6 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand
|
|||
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
||||
settings.addInstance(new_instance)
|
||||
visibility_changed = True
|
||||
else:
|
||||
Logger.log("w", "Unable to add instance (%s) to per-object visibility because we couldn't find the matching definition", item)
|
||||
|
||||
if visibility_changed:
|
||||
self.visibilityChanged.emit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue