<div dir="ltr">Hi!<div><br></div><div>I am debugging an issue where <a href="https://krita-artists.org/t/active-layer-not-updated-in-plugin/81240">changing a layer within a python script does not affect the activeNode() until the script is finished executing</a>.</div><div><br></div><div>Here's what I found:</div><div>Within KisNodeManager::Private::activateNodeImpl, there is code that gets a shape for the node. In the script, this shape ends up being Null, so the function fails <a href="https://github.com/KDE/krita/blob/c237d74b5765896e19e481f47e082bbb6cc9816d/libs/ui/kis_node_manager.cpp#L165">this assert</a> and never gets to "<a href="https://github.com/KDE/krita/blob/c237d74b5765896e19e481f47e082bbb6cc9816d/libs/ui/kis_node_manager.cpp#L177">imageView->setCurrentNode</a>".</div><div><br></div><div>I've placed a breakpoint in <a href="https://github.com/KDE/krita/blob/c237d74b5765896e19e481f47e082bbb6cc9816d/libs/ui/flake/kis_node_dummies_graph.cpp#L116">KisNodeDummiesGraph::addNode</a> and found that it gets called when copying a layer manually, but not when it's done in the script.<br></div><div><br></div><div>Chasing this upstream, I found that the KisNodeDummiesGraph::addNode is called in response to a QEvent within KisSynchronizedConnectionBase::event but now I'm getting a little lost.</div><div><br></div><div>Any pointers on how I could continue chasing this down?</div><div>I don't understand what the "Shape" is and at which point in the flow it is supposed to be added for a new layer.</div></div>