Bug 454960

Summary: Multiple local selection layers aren't saved
Product: [Applications] krita Reporter: denverpuccetti.obsyden
Component: Tools/SelectionAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: ahab.greybeard, halla
Priority: NOR Keywords: triaged
Version First Reported In: 5.0.6   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Left: before saving multiple selections without a parent layer. Right: after re-loading the save of the left

Description denverpuccetti.obsyden 2022-06-07 09:33:54 UTC
SUMMARY
Multiple local selection layers aren't saved


STEPS TO REPRODUCE
1. Create multiple local selection layers
2. Drag them all onto one layer
3. Save the file

OBSERVED RESULT
Only one or two local selection layers are saved with the file, the rest aren't saved.

EXPECTED RESULT
All local selection layers should be saved.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kubuntu 22.04
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3
Comment 1 Halla Rempt 2022-06-07 09:36:05 UTC
I cannot reproduce this.
Comment 2 denverpuccetti.obsyden 2022-06-07 10:26:58 UTC
Created attachment 149525 [details]
Left: before saving multiple selections without a parent layer. Right: after re-loading the save of the left

Left: before saving multiple selections without a parent layer. Right: after re-loading the save of the left
Comment 3 denverpuccetti.obsyden 2022-06-07 10:27:33 UTC
My bad, the conditions upon which it appears are when multiple local selection layers are present and NOT parented to any layer. Not all of them are saved, and for some reason one is always placed on the top of the layer stack when the save is re-loaded?
Comment 4 Halla Rempt 2022-06-07 12:54:56 UTC
But how have you actually managed to create local selection masks that are not parented by a layer? If I try that, the mask becomes the global selection again.
Comment 5 denverpuccetti.obsyden 2022-06-07 22:40:51 UTC
I drag all the local selection layers to the bottom of the layer stack. I thought this was standard functionality?
Comment 6 Halla Rempt 2022-06-08 08:35:55 UTC
No... selection masks are masks, not layers, and they are always supposed to be attached to a layer. Actually being able to do this is a bug in itself.
Comment 7 denverpuccetti.obsyden 2022-06-08 08:54:32 UTC
Despite it being a bug, I've actually found this very useful, as having parentless selection masks allows them to be activated while selecting any layer OR another mask. I'm using this 'functionality' to paint on a transparency mask with a local selection active (which I can't do if the local selection is parented to anything, even including the layer the mask belongs to.)
Comment 8 Ahab Greybeard 2022-06-08 13:44:20 UTC
If no Global Selection Mask is active, a Local Selection Mask can be dragged to the bottom or top of the layer stack to become a Global Selection Mask.
You can have a large number of Global Selection Masks but only one of them can be active.
Similarly, you can have a large number of Local Selection Masks on a paint layer but only one of them can be active.
You can drag a Global Selection Mask onto a paint layer where it will become a Local Selection Mask.

If you Save then only one Global Selection Mask is preserved but all Local Selection Masks are saved.

I store Selection Masks as Local Selection Masks attached to a 'storage layer' to preserve them.

It would be useful if multiple Global Selection Masks could be saved and restored.
Comment 9 denverpuccetti.obsyden 2022-06-09 00:03:37 UTC
Aha, so that's what this is called. Yes, what I seem to have reported as a bug is in fact that GLOBAL selection masks aren't all saved with the file.
Comment 10 Ahab Greybeard 2022-06-10 18:34:53 UTC
I'll Confirm this for the 5.0.6 and the Jun 10 5.1.0-prealpha (git ab9510e8c9) appimages on Debian 10.

Multiple Global Selection Masks can be created and exist in a stable and useful way in the Layers docker.

However, after Saving, only one Global Selection Mask is preserved in the .kra file.

A workaround for this is to drag the Global Selection Masks onto a 'storage layer' so that they are converted to Local Selection Masks, which are preserved in the .kra file after Saving.
Comment 11 Dmitry Kazakov 2022-06-22 12:48:04 UTC
Git commit 7f226b9e9c41f1e3520a28f1a52bcaa75b6947d3 by Dmitry Kazakov.
Committed on 22/06/2022 at 12:47.
Pushed by dkazakov into branch 'master'.

Fix lost masks when opening a document with two root inactive selection masks

M  +1    -1    libs/image/kis_group_layer.cc
M  +15   -2    plugins/impex/libkra/kis_kra_loader.cpp

https://invent.kde.org/graphics/krita/commit/7f226b9e9c41f1e3520a28f1a52bcaa75b6947d3
Comment 12 Dmitry Kazakov 2022-06-22 12:54:18 UTC
Git commit c44cc4efc13256da2bfd5d3fa74a728097fb9def by Dmitry Kazakov.
Committed on 22/06/2022 at 12:48.
Pushed by dkazakov into branch 'krita/5.1'.

Fix lost masks when opening a document with two root inactive selection masks

M  +1    -1    libs/image/kis_group_layer.cc
M  +15   -2    plugins/impex/libkra/kis_kra_loader.cpp

https://invent.kde.org/graphics/krita/commit/c44cc4efc13256da2bfd5d3fa74a728097fb9def