NodeGraphQt icon indicating copy to clipboard operation
NodeGraphQt copied to clipboard

Dictionary iteration error when dealing with subgraphs

Open herronelou opened this issue 7 months ago • 1 comments

Hello,

I found an issue with expanding graphs:

https://github.com/jchanvfx/NodeGraphQt/blob/a8fa9b394d35bf4fcad3c241ec1bd7a98b40bb1c/NodeGraphQt/base/graph.py#L2958

At this line 👆 you iterate though the items of an internal dict. A few lines lower, within the iteration there is this call: 👇

https://github.com/jchanvfx/NodeGraphQt/blob/a8fa9b394d35bf4fcad3c241ec1bd7a98b40bb1c/NodeGraphQt/base/graph.py#L2962

However, the function called from there 👆 is modifying the same internal dict 👇

https://github.com/jchanvfx/NodeGraphQt/blob/a8fa9b394d35bf4fcad3c241ec1bd7a98b40bb1c/NodeGraphQt/base/graph.py#L2997

As a result, it raises RuntimeError: dictionary changed size during iteration

This is likely a result of a Python2 to Python3 change, where the result of dict.items() changed from a list to an iterator.

herronelou avatar Apr 09 '25 07:04 herronelou