Bug 405686

Summary: Merge layers can cause the merged layer to be in a different position in the layer stack
Product: [Applications] krita Reporter: Tiar <tamtamy.tymona>
Component: Layer StackAssignee: Tiar <tamtamy.tymona>
Severity: normal CC: halla
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Test .kra file

Description Tiar 2019-03-20 13:24:48 UTC
Created attachment 118936 [details]
Test .kra file

When you merge layers from the example file in the order provided in the "steps" section, the merged layer will be appear at the top of the layer stack instead of being one layer below. Thus the projection is different before and after merge.

1. Open the provided file.
2. Select layers: Layer 5, Layer 3, Layer 2, Layer 4. (For example: select layer 5; hold Shift; select layer 4.) The active layer must be layer 4.
3. Use shortcut (default: ctrl+E), Layer -> Merge with layer below, or right-click on the layer 4 (important!) and select "Merge with layer below".

The result layer appears on top of the layer stack instead of the correct position.

The result layer should be one layer below the top of the layer stack.

- If layer 5 is selected or you right-click on layer 5, the result layer will be in a correct position.
- If you undo, the selected layer will be only Layer 5 and Layer 3.

The test file is a modified version of a file from bug 405366.


 Version: 4.2.0-pre-alpha (git fbba406)
 Languages: pl
 Hidpi: false


  Version (compiled): 5.11.3
  Version (loaded): 5.11.3

OS Information

  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.15.0-45-generic
  Pretty Productname: Linux Mint 19.1
  Product Type: linuxmint
  Product Version: 19.1

Hardware Information

  GPU Acceleration: auto
  Memory: 7771 Mb
  Number of Cores: 4
  Swap Location: /tmp

Git hash: fbba406b15d7f6b066fd40
Comment 1 Halla Rempt 2019-04-04 09:49:40 UTC
Yes, I can confirm this still happens.
Comment 2 Tiar 2019-04-09 09:12:15 UTC
Git commit 214d419c911ba18d7989865ae5bf6fd2b0fdd045 by Agata Cacko.
Committed on 09/04/2019 at 09:09.
Pushed by tymond into branch 'master'.

Fix wrong position of the merged layer

Before this patch, if you had a standard layer, then group
layer, then two more layers inside the group and tried to
merge them, selecting all and keeping the last mentioned layer
(inside the group) selected, the merged layer appeared on top
of the layers stack instead of the place of source layers.
After this commit, the merged layer is put in the place of
the active layer.

M  +12   -17   libs/image/kis_layer_utils.cpp