Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions python/shotgun_model/shotgun_query_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,15 @@ def __do_depth_first_tree_deletion(self, node):

# delete the child leaves
for index in range(node.rowCount(), 0, -1):
# Use `takeRow` instead of `removeRow` to prevent model from deleting
# the data before we're done using it. takeRow does not free the memory
# but we own the objects and do not keep a reference to it, so garbage
# collection will take care of freeing up the memory for us.
node.takeRow(index - 1)
if sgtk.platform.current_engine().instance_name == "tk-houdini":

Copilot AI May 15, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider caching the result of sgtk.platform.current_engine() before the loop if the engine is not expected to change, to avoid redundant calls on every iteration.

Copilot uses AI. Check for mistakes.
node.removeRow(index - 1)
else:

Copilot AI May 15, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that for non-Houdini engines the intended node.takeRow(index - 1) call is executed as the diff only shows a comment in this branch.

Copilot uses AI. Check for mistakes.
# For every other engine,
# Use `takeRow` instead of `removeRow` to prevent model from deleting
# the data before we're done using it. takeRow does not free the memory
# but we own the objects and do not keep a reference to it, so garbage
# collection will take care of freeing up the memory for us.
node.takeRow(index - 1)

def __remove_unique_id_r(self, item):
"""
Expand Down