Bug 372695

Summary: data loss when duplicating animated layer and editing
Product: [Applications] krita Reporter: Bollebib <kwadraatnope>
Component: AnimationAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: grave CC: animtim, halla, joupent
Priority: NOR    
Version First Reported In: 3.0.2 Alpha   
Target Milestone: ---   
Platform: Other   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Bollebib 2016-11-20 11:08:52 UTC
1)Make an animation,and duplicate it.
2)now delete or move frames on the duplicated layer.
3)Save and reopen the file.
=>the original layer will have the same changes made to it as you did to the duplicated layer.


only way to solve this is to duplicate->save->close->reopen

so there is a workaround,but this bug IS dangerous and has resulted in data loss for me as I didn't know or forgot about this issue.
Comment 1 Bollebib 2016-11-20 11:14:39 UTC
A way to see that the layers are linked is to change the color of a single frame
->linked frames will change color



While this is something that could be useful for future features that have been discussed (linked frames)this is actually the wrong way to go as it doesnt provide any visual feedback,and creating a linked frame should be a concious choice,not an accidental one.
Comment 2 animtim 2016-11-20 11:34:09 UTC
Ok I can confirm this, it is a serious bug.

Note: I made a first test where I duplicated a layer with 3 frames, and deleted 1 frame on each (not the same), saved and reopened: no problem.. but then I tried again and this time just moved frames on the duplicate: 
there it affected the original layer after reload.
Comment 3 joupent 2016-11-20 11:51:48 UTC
I don't have a system capable of compiling Krita right now, but I have found the cause of the bug.

This is the result of making a shallow copy of the keyframe map when duplicating a keyframe channel (kis_keyframe_channel.cpp:46). Instead, we should also clone the keyframes themselves.
Comment 4 Halla Rempt 2016-11-21 10:08:16 UTC
Jouni, 

Will you have time and a system to fix this issue this week? We're going to need this fixed for next week's RC. I tried to look into it, but I'm not getting the seemingly circular relationship between KisKeyFrame and KisKeyFrameChannel.
Comment 5 joupent 2016-11-23 09:15:12 UTC
I have Krita compiling again now. I should be able to fix this by the RC.
Comment 6 joupent 2016-11-24 13:32:33 UTC
Git commit 05cce0cc43c7477a53ff19e338f9b64a23eb6afc by Jouni Pentikäinen.
Committed on 24/11/2016 at 13:30.
Pushed by jounip into branch 'rempt/impex-refactoring'.

Fix sharing keyframe data when duplicating animated layers

M  +9    -0    libs/image/kis_keyframe.cpp
M  +9    -0    libs/image/kis_keyframe.h
M  +4    -1    libs/image/kis_keyframe_channel.cpp
M  +13   -0    libs/image/kis_raster_keyframe_channel.cpp
M  +10   -0    libs/image/kis_scalar_keyframe_channel.cpp
M  +12   -0    plugins/tools/tool_transform2/kis_transform_args_keyframe_channel.cpp

https://commits.kde.org/krita/05cce0cc43c7477a53ff19e338f9b64a23eb6afc
Comment 7 Halla Rempt 2017-06-05 09:56:28 UTC
Git commit aae68408391c802a1026e0ead2a8a52cbf0614c9 by Boudewijn Rempt, on behalf of Jouni Pentikäinen.
Committed on 05/06/2017 at 09:56.
Pushed by rempt into branch 'krita/3.2'.

Fix sharing keyframe data when duplicating animated layers

M  +9    -0    libs/image/kis_keyframe.cpp
M  +9    -0    libs/image/kis_keyframe.h
M  +4    -1    libs/image/kis_keyframe_channel.cpp
M  +13   -0    libs/image/kis_raster_keyframe_channel.cpp
M  +10   -0    libs/image/kis_scalar_keyframe_channel.cpp
M  +12   -0    plugins/tools/tool_transform2/kis_transform_args_keyframe_channel.cpp

https://commits.kde.org/krita/aae68408391c802a1026e0ead2a8a52cbf0614c9