Bug 293314

Summary: Tricky flatten undo bug with 3 layers
Product: [Applications] krita Reporter: Dmitry Kazakov <dimula73>
Component: GeneralAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:

Description Dmitry Kazakov 2012-02-04 17:48:10 UTC
Thanks Animtim for the report:

Found a little undo bug:
-Create a group layer
-inside, create 3 empty layers, draw something on each
-On the group layer, do "Flatten layer".
-Undo
->the bottom layer in the group "disappear" from canvas, just toggle its visibility off/on to see it again.

It is present in both: master and shapes-as-node-model-kazakov
Comment 1 Dmitry Kazakov 2012-02-05 12:02:02 UTC
Git commit 966108cbcd3d5d56db4ac48c9d89bcb20c3c84ad by Dmitry Kazakov.
Committed on 05/02/2012 at 13:59.
Pushed by dkazakov into branch 'shapes-as-node-model-kazakov'.

Fixed a really tricky bug in walkers

https://bugs.kde.org/show_bug.cgi?id=293314
He-he ;)

It happened due to the following:
1) Undo of removeLayer command added a layer and issued setDirty
   for this node
2) The scheduler calculated the walker for this update and put it
   into the queue
3) Undo of addLayer command removed one of the layers of the stack,
   leaving the queued walker in a very interesting state.

The point is that the walker stored a shared pointer to the removed
node, so it still had access to it and there were no crashes, but its
behavior was not obvious (read "unpredictable").

So I extended the meaning of the walker's checksum. Now it depends on
the graph sequence number as well, so the walker is recalculated when
he gets to know its data is outdated.

About Graph Sequence Number.

Now KisNodeGraphListener maintains an integer which shows current "version"
of the graph or its "sequence number". This integer is incremented on every
change made to the graph. So if you have some information about the graph
which was acquired while the sequence number was X and now you see the number
equals to Y, you should know your information is outdated and someone has
changed the graph since then.

M  +1    -0    krita/image/CMakeLists.txt
M  +9    -1    krita/image/kis_async_merger.cpp
M  +11   -1    krita/image/kis_base_rects_walker.h
M  +11   -44   krita/image/kis_image.cc
M  +0    -4    krita/image/kis_image.h
M  +5    -0    krita/image/kis_node.cpp
M  +7    -0    krita/image/kis_node.h
A  +79   -0    krita/image/kis_node_graph_listener.cpp     [License: GPL (v2+)]
M  +33   -9    krita/image/kis_node_graph_listener.h
M  +35   -0    krita/image/tests/kis_node_graph_listener_test.cpp
M  +1    -0    krita/image/tests/kis_node_graph_listener_test.h
M  +45   -1    krita/image/tests/kis_walkers_test.cpp
M  +2    -1    krita/image/tests/kis_walkers_test.h
M  +12   -15   krita/sdk/tests/testutil.h
M  +1    -9    krita/ui/widgets/kis_scratch_pad.cpp

http://commits.kde.org/calligra/966108cbcd3d5d56db4ac48c9d89bcb20c3c84ad