<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>520729</bug_id>
          
          <creation_ts>2026-05-27 18:26:12 +0000</creation_ts>
          <short_desc>setActiveNode activates WRONG node sometimes</short_desc>
          <delta_ts>2026-05-28 17:33:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>krita</product>
          <component>Scripting</component>
          <version>5.3.2</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>520744</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="IPv6">razinkov</reporter>
          <assigned_to name="Krita Bugs">krita-bugs-null</assigned_to>
          <cc>tamtamy.tymona</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2518783</commentid>
    <comment_count>0</comment_count>
    <who name="IPv6">razinkov</who>
    <bug_when>2026-05-27 18:26:12 +0000</bug_when>
    <thetext>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: &quot;WARNING: TimelineFramesModel::slotCurrentNodeChanged: node not found!&quot;

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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2518784</commentid>
    <comment_count>1</comment_count>
    <who name="IPv6">razinkov</who>
    <bug_when>2026-05-27 18:26:53 +0000</bug_when>
    <thetext>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()) &gt; 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(&quot;Background&quot;, doc.rootNode())
doc.setActiveNode(layerNode)
doc.waitForDone()
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2518842</commentid>
    <comment_count>2</comment_count>
    <who name="Tiar">tamtamy.tymona</who>
    <bug_when>2026-05-27 23:56:10 +0000</bug_when>
    <thetext>Related or duplicate of bug 478763. I don&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2518916</commentid>
    <comment_count>3</comment_count>
    <who name="IPv6">razinkov</who>
    <bug_when>2026-05-28 09:31:12 +0000</bug_when>
    <thetext>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)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2519005</commentid>
    <comment_count>4</comment_count>
    <who name="Tiar">tamtamy.tymona</who>
    <bug_when>2026-05-28 15:30:44 +0000</bug_when>
    <thetext>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 &quot;Artifacts&quot; folder). If it also works correctly, then this bug report is a duplicate of bug 520744, I think.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2519040</commentid>
    <comment_count>5</comment_count>
    <who name="IPv6">razinkov</who>
    <bug_when>2026-05-28 17:29:06 +0000</bug_when>
    <thetext>(In reply to Tiar from comment #4)
&gt; In that case, could you please test MR
&gt; 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2519041</commentid>
    <comment_count>6</comment_count>
    <who name="Tiar">tamtamy.tymona</who>
    <bug_when>2026-05-28 17:33:34 +0000</bug_when>
    <thetext>Setting as duplicate, then. Please reopen if you do see issues.

*** This bug has been marked as a duplicate of bug 520744 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>