Bug 457154

Summary: Crash after copy-pasting a selection of a group (projection) containing vector layer, reproducible + backtrace
Product: [Applications] krita Reporter: David REVOY <info>
Component: Layer StackAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description David REVOY 2022-07-26 09:43:28 UTC
Hi,

Here is a crash I can reproduce after copying and pasting a part of a group.

To reproduce:
===========
1. Get my sample Krita file: https://www.peppercarrot.com/extras/temp/2022-07-26_crash-group.kra (4.7MB)
2. The group named "group" in the layer stack should be selected after opening
3. Take the rectangular selection tool (Ctrl+R) and select a part of the artwork
4. Press Ctrl+C to copy the group
5. Press Ctrl+V

Result:
======
Krita crashes, 
```
Thread 1 "krita" received signal SIGSEGV, Segmentation fault.
0x00007ffff6757200 in KisImage::xRes() const () from /tmp/.mount_krita-dtXgAb/usr/bin/../lib/libkritaimage.so.18
```
Full backtrace is here: https://paste.chapril.org/?8dcb04d394bc545b#BjSgZhSCDfQTPMAqoB7HQPvwWJ3wYMdE6KFh31i4nuXs

Expected:
========
Krita paste the selection as a new group.

Origins & Investigation:
===================
- I can't reproduce it in 2022-07-08_13h22__krita-5.1.0-beta2-a1e3eff619-x86_64.appimage  and under
- I can on: 2022-07-11_09h54__krita-5.1.0-beta2-09d1d958fb-x86_64.appimage (and all 5.1~nightly appimages up to today)
So, it happened in a commit between 8 july to 11 july ... but I'm not skilled to blame the exact commit on https://invent.kde.org/graphics/krita/-/commits/krita/5.1/ , that's where my investigation is ending. :-) 

Setup:
=====
Fedora 36 KDE. Mesa 
GPU: AMD ATI Radeon RX 5500/5500M / Pro 5500M
CPU: AMD Ryzen 7 3700X (16) @ 3.600GHz
VM: Kwin/X11
DE: KDE Plasma 5.24.5
Krita Version: 5.1.0-beta1
Qt version compiled: 5.12.12, loaded: 5.12.12.
Comment 1 Dmitry Kazakov 2022-07-26 11:17:29 UTC
Git commit 0d36611b536883fa371ffa763e5e5af192eae8b7 by Dmitry Kazakov.
Committed on 26/07/2022 at 11:17.
Pushed by dkazakov into branch 'master'.

Fix a crash when copy-pasting a group with vector layers

The node should be explicitly detached from the image before
this image gets deteled. Normally it is done by the image's
destructor, but the copies layers are not officially added
to the image.

M  +1    -0    libs/ui/actions/kis_selection_action_factories.cpp
M  +4    -1    libs/ui/kis_mimedata.cpp

https://invent.kde.org/graphics/krita/commit/0d36611b536883fa371ffa763e5e5af192eae8b7
Comment 2 Dmitry Kazakov 2022-07-26 11:17:33 UTC
Git commit 28791acadffcbed80c73a2e23c193ab5ab8fcab3 by Dmitry Kazakov.
Committed on 26/07/2022 at 11:17.
Pushed by dkazakov into branch 'krita/5.1'.

Fix a crash when copy-pasting a group with vector layers

The node should be explicitly detached from the image before
this image gets deteled. Normally it is done by the image's
destructor, but the copies layers are not officially added
to the image.

M  +1    -0    libs/ui/actions/kis_selection_action_factories.cpp
M  +4    -1    libs/ui/kis_mimedata.cpp

https://invent.kde.org/graphics/krita/commit/28791acadffcbed80c73a2e23c193ab5ab8fcab3