Bug 327571 - Krita crashes when opening a particular saved .kra file.
Summary: Krita crashes when opening a particular saved .kra file.
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 2.8 Pre-Alpha
Platform: unspecified Microsoft Windows
: NOR critical
Target Milestone: ---
Assignee: Dmitry Kazakov
URL: https://dl.dropboxusercontent.com/u/1...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-13 17:58 UTC by mc3dkid
Modified: 2013-11-27 21:35 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
This is the file with the clone layers stripped out -- it at least opens now. (2.34 MB, application/x-krita)
2013-11-14 15:45 UTC, Halla Rempt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mc3dkid 2013-11-13 17:58:46 UTC
A file that I have been working on now causes Krita to crash when attempting to open it from within the application as well as trying to open it via Windows Explorer.  The .kra~  has the same issue. 

Reproducible: Couldn't Reproduce
Comment 1 Halla Rempt 2013-11-14 08:59:54 UTC
Hi! Can you please attach the file to the bug?
Comment 2 Dmitry Kazakov 2013-11-14 10:08:38 UTC
Probably, it was the recent openGL issue, which is fixed in master...
Yes, we need the file to test it.
Comment 3 Sven Langkamp 2013-11-14 15:05:33 UTC
The file is linked above under URL.
Comment 4 mc3dkid 2013-11-14 15:27:20 UTC
I added a link to the files location in the bug because  I didn't see how to attach it.  I will attach it now.
Comment 5 Halla Rempt 2013-11-14 15:37:57 UTC
Ah....
Comment 6 Halla Rempt 2013-11-14 15:38:31 UTC
And I can confirm the crash....
Comment 7 Halla Rempt 2013-11-14 15:44:48 UTC
Hm... There are three clone layers in the file, all of them referring to a layer no longer seems to exist. I'm not sure how Krita could have gotten in that state.
Comment 8 Halla Rempt 2013-11-14 15:45:43 UTC
Created attachment 83563 [details]
This is the file with the clone layers stripped out -- it at least opens now.
Comment 9 mc3dkid 2013-11-14 16:37:45 UTC
Thanks, I really appreciate the save!  I will be sure to keep an eye out for this problem in the future.
Comment 10 Halla Rempt 2013-11-15 09:15:11 UTC
You're welcome. I'm really sorry about the problems (and I'm a bit worried that I cannot figure out how krita could've gotten into this state...) I think we need a kind of sanity checker on save and an load...
Comment 11 Dmitry Kazakov 2013-11-27 05:48:47 UTC
I looked into the resulting XML file and it looks like the UUID of the clone layer sources are handled somehow wrongly. That is the source of the clones exist in the image, the clone has correct 'clonefrom' value, but 'clonefromuuid' is incorrect. 

Such situation might be caused either by the bug in the saving code, or some non-synchronized updates of the UUIDs when moving/creating/renaming.

The relevant piece of XML:

<layer opacity="194" x="115" nodetype="clonelayer" y="110" clonefrom="Skull" visible="1" collapsed="0" compositeop="overlay" locked="0" uuid="{5b873ac9-2873-4220-97f9-3b02622e6443}" name="Skull2" clonefromuuid="{c8eafad2-01fa-4efd-977b-651d03fb1019}" clonetype="0" filename="layer30" channelflags=""/>

<layer opacity="82" x="106" channellockflags="1111" nodetype="paintlayer" y="101" colorspacename="RGBA" visible="1" collapsed="0" compositeop="normal" locked="0" uuid="{298953d9-6b84-44d5-a4c8-403e02195abe}" name="Skull" filename="layer31" channelflags="1111"/>

You can see that the relevant source layer exists, but has different uuid.
Comment 12 Dmitry Kazakov 2013-11-27 07:16:34 UTC
Ok, I've managed to reproduce this bug. There are two actually:

1st bug:
1) Create a Group Layer, add a Paint Layer into it
2) Create a Clone of a Paint Layer and move it outside of the Group
3) Remove the Group Layer (the paint layer will be removed transitively)

Now the Clone Layer points to nothing (technically, to the layer still stored in the undo information). The file can be saved, but will fail to open, obviously.


2nd bug:
1) Create a Group Layer. Add a Paint Layer and a clone to it.
2) Group Layer -> Duplicate Layer or Mask

The clone in the newly created Group Layer will point to the source in the old Group Layer, which is actually not what we wanted to achieve. And due to the Bug1 deletion of the first Group will break clones of the second group.
Comment 13 Dmitry Kazakov 2013-11-27 07:17:04 UTC
I'll try to fix it.
Comment 14 Dmitry Kazakov 2013-11-27 21:35:56 UTC
Git commit 18140e5b26e6532f51ffdb459f1b0e426ec80c94 by Dmitry Kazakov.
Committed on 27/11/2013 at 21:33.
Pushed by dkazakov into branch 'master'.

Fixed bugs in transitive reincarnation of the Clone Layers

This patch fixes two problems:
1) The Duplicate of a Group Layer will reset links inside internal
   Clone Layers properly.
2) The removal of a group layer will reincarnate all the clone layers
   which were connected to the descendants of that layer.

M  +1    -0    krita/image/CMakeLists.txt
M  +3    -3    krita/image/commands/kis_image_command.cpp
M  +1    -1    krita/image/commands/kis_image_command.h
M  +20   -91   krita/image/commands/kis_image_layer_remove_command.cpp
M  +10   -23   krita/image/commands/kis_image_layer_remove_command.h
C  +38   -32   krita/image/commands/kis_image_layer_remove_command_impl.cpp [from: krita/image/commands/kis_image_layer_remove_command.cpp - 055% similarity]
C  +7    -12   krita/image/commands/kis_image_layer_remove_command_impl.h [from: krita/image/commands/kis_image_layer_remove_command.h - 071% similarity]
M  +72   -1    krita/image/kis_node.cpp
M  +86   -0    krita/image/tests/kis_clone_layer_test.cpp
M  +4    -0    krita/image/tests/kis_clone_layer_test.h
M  +2    -9    krita/sdk/tests/qimage_based_test.h
M  +12   -0    krita/sdk/tests/testutil.h
M  +1    -1    krita/ui/kra/kis_kra_loader.cpp

http://commits.kde.org/calligra/18140e5b26e6532f51ffdb459f1b0e426ec80c94