Bug 474122

Summary: Warning logged when undoing Flatten Layer
Product: [Applications] krita Reporter: Freya Lupen <penguinflyer2222>
Component: Layer StackAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:

Description Freya Lupen 2023-09-04 02:44:05 UTC
SUMMARY
Undoing Flatten Layer logs from KisAsyncMerger::startMerge
> BUG: The walker hasn't reached the root layer!
>      Start node: KisGroupLayer(0x6000027b1fc0, name = "Copy of Group 3") Requested rect: QRect(0,0 512x512)
>      An inconsistency in the walkers occurred!
>      Please report a bug describing how you got this message.

STEPS TO REPRODUCE
1. Open a document, make some layers, Quick Group them and then Merge Group.
2. Undo the Flatten Layer step.

OBSERVED RESULT
A warning.

EXPECTED RESULT
No warning.

SOFTWARE/OS VERSIONS
Krita 5.3.0-prealpha git 7df07038
Comment 1 Dmitry Kazakov 2023-09-19 13:42:47 UTC
Hi, Freya!

Could you  please send me the testing image you use to reproduce the bug? I cannot reproduce it here it seems ;(
Comment 2 Freya Lupen 2023-09-19 14:26:27 UTC
On further testing, it only happens if there is another layer beneath the Group Layer.
I'd used a new document with a locked Background layer and grouped two Paint Layers on top of it.
Comment 3 Bug Janitor Service 2024-02-13 09:18:23 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/2070
Comment 4 Dmitry Kazakov 2024-02-13 12:38:12 UTC
Git commit e0d1ae3c174fbb05880b65d58ff4a35c68d642aa by Dmitry Kazakov.
Committed on 13/02/2024 at 09:15.
Pushed by dkazakov into branch 'master'.

Fix a warning on undoing flattening a group

When updates are issued in the middle of layer addition/removal
it may happen that some updates will never reach the root node,
which is a bug. And the warning told us about that.

The patch moves the updates into a separate command that emits them
in a batch **after** all node modifications are finished.

M  +1    -0    libs/image/CMakeLists.txt
A  +101  -0    libs/image/commands/KisBatchUpdateLayerModificationCommand.cpp     [License: GPL(v2.0+)]
A  +52   -0    libs/image/commands/KisBatchUpdateLayerModificationCommand.h     [License: GPL(v2.0+)]
M  +1    -1    libs/image/commands/kis_image_command.h
M  +54   -35   libs/image/kis_layer_utils.cpp
M  +13   -0    libs/image/kis_layer_utils.h

https://invent.kde.org/graphics/krita/-/commit/e0d1ae3c174fbb05880b65d58ff4a35c68d642aa