Skip to content

Commit

Permalink
fix bug where action where being shown which should have remained hid…
Browse files Browse the repository at this point in the history
…den.

this happend because we where removing actions from the list as we iterate. causing it it skip actions.

also added a quicker way for actions to exit out of the loop if we only want to know if any actions are visible.
  • Loading branch information
Lars van der Bijl committed Nov 25, 2016
1 parent cad2f8c commit 3c86cd6
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions pyblish_lite/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,15 @@ def data(self, index, role):
actions = list(item.actions)

# Context specific actions
for action in actions:
if action.on == "failed" and not item._has_failed:
actions.remove(action)
if action.on == "succeeded" and not item._has_succeeded:
actions.remove(action)
if action.on == "processed" and not item._has_processed:
actions.remove(action)
if action.on == "notProcessed" and item._has_processed:
actions.remove(action)

if actions:
return True
for action in reversed(actions):
if action.on == "failed" and item._has_failed:
return True
if action.on == "succeeded" and item._has_succeeded:
return True
if action.on == "processed" and item._has_processed:
return True
if action.on == "notProcessed" and not item._has_processed:
return True

return False

Expand All @@ -241,7 +238,7 @@ def data(self, index, role):
actions = list(item.actions)

# Context specific actions
for action in actions:
for action in actions[:]:
if action.on == "failed" and not item._has_failed:
actions.remove(action)
if action.on == "succeeded" and not item._has_succeeded:
Expand Down

0 comments on commit 3c86cd6

Please sign in to comment.