Bug 520729 - setActiveNode activates WRONG node sometimes
Summary: setActiveNode activates WRONG node sometimes
Status: RESOLVED DUPLICATE of bug 520744
Alias: None
Product: krita
Classification: Applications
Component: Scripting (other bugs)
Version First Reported In: 5.3.2
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-27 18:26 UTC by IPv6
Modified: 2026-05-28 17:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description IPv6 2026-05-27 18:26:12 UTC
DESCRIPTION

I have addon that selects layer with python API
```
doc.setActiveNode(layerNode)
doc.waitForDone()
```
With Recent 5.3.2 activating layer via API activates wrong Node sometimes, not the one in layerNode.
It happens sporadically, the console prints a warning: "WARNING: TimelineFramesModel::slotCurrentNodeChanged: node not found!"

When this warning happens - wrong node is selected. Node is perfectly valid, not a None, it is found by doc.nodeByUniqueID before call with some extra logic.

I failed to create reproducible KRA file. Probably the reason my KRA is really heavy on hierarchy (many different layers with clones, filters, groups, some groups closed etc)

It worked flawlessly in 5.3.1

SOFTWARE/OS VERSIONS
OS: macOS 26.5
Krita Version: 5.3.2 (git 7d1ae74)
Qt Version (loaded): 5.15.7
Comment 1 IPv6 2026-05-27 18:26:53 UTC
Code used to find layer before activation roughly:


```
def lfind(layerName, parentLayer):
    for layer in reversed(parentLayer.childNodes()):
        if layerName == layer.name():
            return layer
        if len(layer.childNodes()) > 0:
            returned = lfind(layerName, layer)
            if returned is not None:
                return returned
    return None

from krita import Krita

app = Krita.instance()
doc = app.activeDocument()

layerNode = lfind("Background", doc.rootNode())
doc.setActiveNode(layerNode)
doc.waitForDone()
```
Comment 2 Tiar 2026-05-27 23:56:10 UTC
Related or duplicate of bug 478763. I don't think it worked flawlessly in 5.3.1, because I had the exact same issues in my plugin Life Drawing Session for a while now.
Comment 3 IPv6 2026-05-28 09:31:12 UTC
I switched back to 5.3.1.1 (since the bug is really annoying with addon i need regularly) - and for me activation code works without issues again, at least for my files. Using krita on MacOs and Windows, can cofirm 5.3.1 is fine for my usecase.

Regarding 5.3.2 what I noticed - it may work several first times after file open - and then stop to work until file is reloaded. Then can work again.
Could be also somehow related to selecting layer inside several nested closed groups with disabled visibility (again, my frequent usecase)
Comment 4 Tiar 2026-05-28 15:30:44 UTC
In that case, could you please test MR https://invent.kde.org/graphics/krita/-/merge_requests/2803 (instruction: https://krita-artists.org/t/how-to-test-a-merge-request-or-a-new-unfinished-feature-instruction/120134 - you gotta choose this pipeline: https://invent.kde.org/graphics/krita/-/pipelines/1250132 and then choose your  OS and find the executable in "Artifacts" folder). If it also works correctly, then this bug report is a duplicate of bug 520744, I think.
Comment 5 IPv6 2026-05-28 17:29:06 UTC
(In reply to Tiar from comment #4)
> In that case, could you please test MR
> https://invent.kde.org/graphics/krita/-/merge_requests/2803

I downloaded MacOs artifact from here - https://invent.kde.org/graphics/krita/-/jobs/4476126 - and seems both issues (setActiveNode and active layer on open) are fixed! At least first tests - everything as it is in 5.3.1. Will continue to use it, hope this pesky commit was the base reason for all that fuzz :)

Sys data of now-working krita: Krita Version: 5.4.0-prealpha (git 9362fb4), Qt version compiled: 5.15.7, loaded: 5.15.7. Process ID: 98765
Comment 6 Tiar 2026-05-28 17:33:34 UTC
Setting as duplicate, then. Please reopen if you do see issues.

*** This bug has been marked as a duplicate of bug 520744 ***