<?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>490843</bug_id>
          
          <creation_ts>2024-07-26 09:00:29 +0000</creation_ts>
          <short_desc>No layer is active after switching between views, except for the last opened view</short_desc>
          <delta_ts>2024-09-05 12:24:45 +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>Layer Stack</component>
          <version>nightly build (please specify the git hash!)</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>regression, release_blocker</keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tyson Tan">tysontanx</reporter>
          <assigned_to name="Dmitry Kazakov">dimula73</assigned_to>
          <cc>halla</cc>
    
    <cc>info</cc>
    
    <cc>reinhart.schultz</cc>
    
    <cc>silver.bullet</cc>
          
          <cf_commitlink>https://invent.kde.org/graphics/krita/-/commit/580a313c993972442b42289c55cb9dae8c98dba6</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>2340256</commentid>
    <comment_count>0</comment_count>
    <who name="Tyson Tan">tysontanx</who>
    <bug_when>2024-07-26 09:00:29 +0000</bug_when>
    <thetext>When opening multiple images all at once, no layer is active except for the last image. The user can&apos;t do anything until they select one layer. Tested with latest nightlies. Noticed since 2024-07-25.

Procedure to reproduce:
1) Prepare 2 images, let&apos;s call them A/B for now;
2) Drag these 2 images together into Krita&apos;s window;
3) Let&apos;s presume image A is opened first, and B opened last;

Result:
1) Only Image B (the last one opened) has an active layer by default.
2) Switch to Image A -- it has no active layer -- and thus cannot be edited.

Expected:
Every image that opened together should have an active layer.

I consider this a bug, because Krita would normally make sure one layer is active for us. This is an inconsistent and confusing behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2340261</commentid>
    <comment_count>1</comment_count>
    <who name="Halla Rempt">halla</who>
    <bug_when>2024-07-26 09:22:44 +0000</bug_when>
    <thetext>I first tested with the files as arguments, and there it works now, but I can confirm the issue with drag &amp; drop.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2340296</commentid>
    <comment_count>2</comment_count>
    <who name="Tyson Tan">tysontanx</who>
    <bug_when>2024-07-26 11:57:08 +0000</bug_when>
    <thetext>Also happens to Main Menu -&gt; File -&gt; Open dialogue with multiple files selected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2340716</commentid>
    <comment_count>3</comment_count>
    <who name="Tyson Tan">tysontanx</who>
    <bug_when>2024-07-28 02:43:03 +0000</bug_when>
    <thetext>I have done some more testing today, and there were new findings.

This bug has nothing to do with &quot;opening files&quot;. It happens when &quot;switching between views that has multiple layers&quot;.

Procedure to reproduce:
1) Open 2 images with multiple layers, let&apos;s call the first image A, and the last image B;
2) Switch to image A, select a layer;
3) Switch to image B, then back to A;

Result:
Image A now has no active layer.

Expected result:
Image A should retain its active layer.

Exception:
If Image A has only 1 layer, that layer will still be active after switching views.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2340895</commentid>
    <comment_count>4</comment_count>
    <who name="Tyson Tan">tysontanx</who>
    <bug_when>2024-07-29 02:27:56 +0000</bug_when>
    <thetext>When drag-and-dropping multiple single layer PNGs into Krita&apos;s window, the original report is still valid.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2341194</commentid>
    <comment_count>5</comment_count>
    <who name="Ralek Kolemios">info</who>
    <bug_when>2024-07-30 06:00:32 +0000</bug_when>
    <thetext>&gt; Procedure to reproduce:
&gt; 1) Open 2 images with multiple layers, let&apos;s call the first image A, and the
&gt; last image B;
&gt; 2) Switch to image A, select a layer;
&gt; 3) Switch to image B, then back to A;
&gt; 
&gt; Result:
&gt; Image A now has no active layer.

To be more specific about what exactly causes it and hopefully help find a fix, a good summary of the exact cause can be described like so:

If you switch away from a document and then switch back, the image will have no active layer unless the last selected layer was also the last created layer.

Doesn&apos;t matter how it was created. pasted, shortcut, duplicating.
It can be any layer type, like filter, or clone, or vector, or mask.
It can be renamed
It can be moved around the layer stack anywhere.
But if it&apos;s not the one selected when you switch documents, nothing will be selected when you switch back.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2341588</commentid>
    <comment_count>6</comment_count>
    <who name="Dmitry Kazakov">dimula73</who>
    <bug_when>2024-07-31 08:47:31 +0000</bug_when>
    <thetext>*** Bug 490636 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2341595</commentid>
    <comment_count>7</comment_count>
    <who name="Dmitry Kazakov">dimula73</who>
    <bug_when>2024-07-31 09:10:31 +0000</bug_when>
    <thetext>Git commit 3b5891816897a868630d3570f044df275bc7a197 by Dmitry Kazakov.
Committed on 31/07/2024 at 09:08.
Pushed by dkazakov into branch &apos;master&apos;.

Fix layer activation issue when opening multiple documents

... and switching between them.

KisNodeManager may emit node change signal right inside setCanvas()
call, which may be received by LayerBox **before** it gto received
its own setCanvas() call. This workaround just checks if the node-to-
be-activated actually belongs to the current image or not.

Ideally, we should make the active layer code a bit more straight-forward
and ensure that there is only one source of truth. But I&apos;m not sure how
to do that right now. Perhaps, during the QML rewite?

M  +14   -0    plugins/dockers/layerdocker/LayerBox.cpp

https://invent.kde.org/graphics/krita/-/commit/3b5891816897a868630d3570f044df275bc7a197</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2341597</commentid>
    <comment_count>8</comment_count>
    <who name="Dmitry Kazakov">dimula73</who>
    <bug_when>2024-07-31 09:11:47 +0000</bug_when>
    <thetext>Git commit 580a313c993972442b42289c55cb9dae8c98dba6 by Dmitry Kazakov.
Committed on 31/07/2024 at 09:11.
Pushed by dkazakov into branch &apos;krita/5.2&apos;.

Fix layer activation issue when opening multiple documents

... and switching between them.

KisNodeManager may emit node change signal right inside setCanvas()
call, which may be received by LayerBox **before** it gto received
its own setCanvas() call. This workaround just checks if the node-to-
be-activated actually belongs to the current image or not.

Ideally, we should make the active layer code a bit more straight-forward
and ensure that there is only one source of truth. But I&apos;m not sure how
to do that right now. Perhaps, during the QML rewite?

M  +14   -0    plugins/dockers/layerdocker/LayerBox.cpp

https://invent.kde.org/graphics/krita/-/commit/580a313c993972442b42289c55cb9dae8c98dba6</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2342024</commentid>
    <comment_count>9</comment_count>
    <who name="Tyson Tan">tysontanx</who>
    <bug_when>2024-08-01 00:59:18 +0000</bug_when>
    <thetext>Thank you, Dmitry!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2351609</commentid>
    <comment_count>10</comment_count>
    <who name="Halla Rempt">halla</who>
    <bug_when>2024-09-05 12:24:45 +0000</bug_when>
    <thetext>*** Bug 492671 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>