Bug 476514

Summary: Flattening a layer detaches its clones
Product: [Applications] krita Reporter: paleh <paleh21669>
Component: Layer StackAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73
Priority: NOR    
Version: 5.2.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description paleh 2023-11-03 16:27:08 UTC
SUMMARY
Flattening a layer with masks or merging a group unlinks the clones of this layer. This is different from bug 351577 as here we're not talking about merging together two layers, one of which has a clone, but about flattening a container, which doesn't change the projection and thus doesn't require any update of the clone other than changing its source. Strictly speaking, this could be a feature request, but I find the absence of this unreasonable enough to be considered a bug.

STEPS TO REPRODUCE
1. Create a paint or a group layer.
2. Create a clone of this layer.
3. Flatten or merge the original layer.

OBSERVED RESULT
The clone is no longer linked to anything, regardless of whether the original layer had any children.

EXPECTED RESULT
The clone is linked to the layer that results from flattening/merging.
Comment 1 Dmitry Kazakov 2023-11-03 17:06:09 UTC
We have some kind of functionality for that in `KisImageLayerRemoveCommandImpl::Private::processClones` but it is not used in flattening.
Comment 2 Dmitry Kazakov 2024-09-16 12:27:02 UTC
Git commit 979965d84c56d118baa9825eebd4d32b3a72d2a7 by Dmitry Kazakov.
Committed on 16/09/2024 at 12:10.
Pushed by dkazakov into branch 'master'.

Relink clones to the new layer when flattening

When flattening a layer we can easily relink all the clones of the
source into the new layer.

M  +1    -0    libs/image/CMakeLists.txt
R  +0    -0    libs/image/commands_new/KisChangeCloneLayersCommand.cpp [from: libs/ui/KisChangeCloneLayersCommand.cpp - 100% similarity]
R  +2    -1    libs/image/commands_new/KisChangeCloneLayersCommand.h [from: libs/ui/KisChangeCloneLayersCommand.h - 085% similarity]
M  +25   -4    libs/image/kis_layer_utils.cpp
M  +1    -0    libs/image/kis_layer_utils.h
M  +0    -1    libs/ui/CMakeLists.txt
M  +1    -1    libs/ui/dialogs/KisDlgChangeCloneSource.cpp

https://invent.kde.org/graphics/krita/-/commit/979965d84c56d118baa9825eebd4d32b3a72d2a7
Comment 3 Dmitry Kazakov 2024-09-16 12:31:56 UTC
Git commit 49c4395642ef9a4b6239aa5209404d1746b9fcc9 by Dmitry Kazakov.
Committed on 16/09/2024 at 12:31.
Pushed by dkazakov into branch 'krita/5.2'.

Relink clones to the new layer when flattening

When flattening a layer we can easily relink all the clones of the
source into the new layer.

M  +1    -0    libs/image/CMakeLists.txt
R  +0    -0    libs/image/commands_new/KisChangeCloneLayersCommand.cpp [from: libs/ui/KisChangeCloneLayersCommand.cpp - 100% similarity]
R  +2    -1    libs/image/commands_new/KisChangeCloneLayersCommand.h [from: libs/ui/KisChangeCloneLayersCommand.h - 085% similarity]
M  +25   -4    libs/image/kis_layer_utils.cpp
M  +1    -0    libs/image/kis_layer_utils.h
M  +0    -1    libs/ui/CMakeLists.txt
M  +1    -1    libs/ui/dialogs/KisDlgChangeCloneSource.cpp

https://invent.kde.org/graphics/krita/-/commit/49c4395642ef9a4b6239aa5209404d1746b9fcc9