Bug 456450

Summary: [subwindow mode] drag and drop a vector layer crashes Krita
Product: [Applications] krita Reporter: David REVOY <info>
Component: Layers/VectorAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: amy, halla
Priority: NOR Keywords: regression, release_blocker
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on: 423752, 452146    
Bug Blocks:    
Attachments: ^ gdb 'thread apply all bt' log of the crash

Description David REVOY 2022-07-07 13:38:11 UTC
Created attachment 150465 [details]
^ gdb 'thread apply all bt' log of the crash

Hi, today I was drag'n'dropping a vector layer with text information (the header for a comission, that has client brand name, number of the sheet, date... a classic) when Krita crashed. I saw it was reproducible with two new documents:

How to reproduce:
===============
1. With the subwindow mode activated (Settings > General > Windows).
2. Create two new documents
3. Window > Tile  (so the two new documents are now side by side)
4. Create a random text on a document.
5. Drag and drop the vector layer containing the txt to the other document

Result:
=====
Krita crashes (gdb 'thread apply all bt' log in attachement).

Expected:
========
The vector layer (with the text) to get copied into the second document (on top of the position in the layer stack) and second document to activate focus.

Hardware and setup:
==================
Krita Version: 5.1.0-beta2  appimage stable nightly (of today 7 july on Jenkins build) , Qt version compiled: 5.12.12, loaded: 5.12.12
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
Comment 1 amyspark 2022-07-07 18:07:08 UTC
Duplicate by revival of 423752, when retrieving Krita node data from the clipboard, shape nodes happily ignore the image assigned in the call to KisMimeData::initializeExternalNode. This seems to go all the way to https://invent.kde.org/graphics/krita/-/commit/9475fe1d7301100ef9245da67f39e646bc1b394f.
Comment 2 amyspark 2022-07-07 18:50:12 UTC
Regression tracked to 81f9b1aac89d3b00e5f357dd235e6c37f002f5fb: 

commit 81f9b1aac89d3b00e5f357dd235e6c37f002f5fb
Author: Dmitry Kazakov <dimula73@gmail.com>
Date:   Thu Apr 7 12:35:23 2022 +0300

    Fix initialization of image link in the pasted nodes
    
    I'm not sure this patch is safe enough for 5.0.x branch.
    
    BUG:452146

https://invent.kde.org/graphics/krita/-/commit/81f9b1aac89d3b00e5f357dd235e6c37f002f5fb#5c6b72611ab77b63397e0ec9999f50a231e504b5_223_225 removes the image reassignment for this particular case.
Comment 3 Dmitry Kazakov 2022-07-08 17:09:43 UTC
Git commit 6531b6b666129cbbd0b61dadafd6bb27b6750629 by Dmitry Kazakov.
Committed on 08/07/2022 at 15:28.
Pushed by dkazakov into branch 'krita/5.1'.

Fix D&D of the shape layers when src and dst resolutions differ

We need to adjust the resolution of the shape layer to fix the
new image in pixel measurements.

M  +13   -3    libs/ui/kis_mimedata.cpp
M  +1    -1    libs/ui/kis_mimedata.h

https://invent.kde.org/graphics/krita/commit/6531b6b666129cbbd0b61dadafd6bb27b6750629
Comment 4 Dmitry Kazakov 2022-07-08 17:09:51 UTC
Git commit 39b5ef7907fe22b120b572fc49887ae83bde16b5 by Dmitry Kazakov.
Committed on 08/07/2022 at 15:28.
Pushed by dkazakov into branch 'krita/5.1'.

Fix a crash when D&D a vector layer from one image to another

The patch does several things

1) Removes "application/x-krita-node" mimedata completely. It was
   used to pass Krita nodes between multiple instances of Krita. Since
   we don't support multiinstance runs anymore, these types should go.
   (they failed in multiple usecases anyway)

2) Implements a special KisDetachedShapesViewConverter converter class
   that is attached to KisShapeLayerCanvasBase, when it has no image
   attached (that was an exact cause of the crash). Now, when the
   vector layer is placed into a mime data, its converter is replaced
   with the detached one to no rely on KisImage (which is deleted at that
   moment)

M  +1    -0    libs/ui/CMakeLists.txt
A  +19   -0    libs/ui/KisClonableViewConverter.h     [License: GPL(v2.0+)]
A  +56   -0    libs/ui/KisDetachedShapesViewConverter.cpp     [License: GPL(v2.0+)]
A  +42   -0    libs/ui/KisDetachedShapesViewConverter.h     [License: GPL(v2.0+)]
M  +13   -14   libs/ui/KisView.cpp
M  +2    -2    libs/ui/KisWelcomePageWidget.cpp
M  +1    -4    libs/ui/flake/KisReferenceImagesLayer.cpp
M  +16   -7    libs/ui/flake/kis_shape_layer.cc
M  +0    -1    libs/ui/flake/kis_shape_layer.h
M  +48   -6    libs/ui/flake/kis_shape_layer_canvas.cpp
M  +11   -5    libs/ui/flake/kis_shape_layer_canvas.h
M  +2    -2    libs/ui/kis_clipboard.cc
M  +4    -9    libs/ui/kis_image_view_converter.cpp
M  +4    -8    libs/ui/kis_image_view_converter.h
M  +33   -87   libs/ui/kis_mimedata.cpp
M  +15   -12   libs/ui/kis_mimedata.h
M  +1    -1    libs/ui/kis_node_model.cpp

https://invent.kde.org/graphics/krita/commit/39b5ef7907fe22b120b572fc49887ae83bde16b5
Comment 5 Dmitry Kazakov 2022-07-08 17:10:19 UTC
Git commit e1b32d773526983ee54a4edfafd146d30ff08b2a by Dmitry Kazakov.
Committed on 08/07/2022 at 15:27.
Pushed by dkazakov into branch 'master'.

Fix a crash when D&D a vector layer from one image to another

The patch does several things

1) Removes "application/x-krita-node" mimedata completely. It was
   used to pass Krita nodes between multiple instances of Krita. Since
   we don't support multiinstance runs anymore, these types should go.
   (they failed in multiple usecases anyway)

2) Implements a special KisDetachedShapesViewConverter converter class
   that is attached to KisShapeLayerCanvasBase, when it has no image
   attached (that was an exact cause of the crash). Now, when the
   vector layer is placed into a mime data, its converter is replaced
   with the detached one to no rely on KisImage (which is deleted at that
   moment)

M  +1    -0    libs/ui/CMakeLists.txt
A  +19   -0    libs/ui/KisClonableViewConverter.h     [License: GPL(v2.0+)]
A  +56   -0    libs/ui/KisDetachedShapesViewConverter.cpp     [License: GPL(v2.0+)]
A  +42   -0    libs/ui/KisDetachedShapesViewConverter.h     [License: GPL(v2.0+)]
M  +13   -14   libs/ui/KisView.cpp
M  +2    -2    libs/ui/KisWelcomePageWidget.cpp
M  +1    -4    libs/ui/flake/KisReferenceImagesLayer.cpp
M  +16   -7    libs/ui/flake/kis_shape_layer.cc
M  +0    -1    libs/ui/flake/kis_shape_layer.h
M  +48   -6    libs/ui/flake/kis_shape_layer_canvas.cpp
M  +11   -5    libs/ui/flake/kis_shape_layer_canvas.h
M  +2    -2    libs/ui/kis_clipboard.cc
M  +4    -9    libs/ui/kis_image_view_converter.cpp
M  +4    -8    libs/ui/kis_image_view_converter.h
M  +33   -87   libs/ui/kis_mimedata.cpp
M  +15   -12   libs/ui/kis_mimedata.h
M  +1    -1    libs/ui/kis_node_model.cpp

https://invent.kde.org/graphics/krita/commit/e1b32d773526983ee54a4edfafd146d30ff08b2a
Comment 6 Dmitry Kazakov 2022-07-08 17:10:27 UTC
Git commit 25e1e1492c0c49424a539fe1a85b59c34ac4a821 by Dmitry Kazakov.
Committed on 08/07/2022 at 15:27.
Pushed by dkazakov into branch 'master'.

Fix D&D of the shape layers when src and dst resolutions differ

We need to adjust the resolution of the shape layer to fix the
new image in pixel measurements.

M  +13   -3    libs/ui/kis_mimedata.cpp
M  +1    -1    libs/ui/kis_mimedata.h

https://invent.kde.org/graphics/krita/commit/25e1e1492c0c49424a539fe1a85b59c34ac4a821
Comment 7 amyspark 2022-08-18 17:20:44 UTC
Git commit abaec2f7bba30800e22811057fb30b0ec0be78ae by L. E. Segovia.
Committed on 18/08/2022 at 17:17.
Pushed by lsegovia into branch 'master'.

KisMimeData: remove leftover parameter from loadNonNativeNodes

M  +2    -3    libs/ui/kis_mimedata.cpp
M  +1    -2    libs/ui/kis_mimedata.h

https://invent.kde.org/graphics/krita/commit/abaec2f7bba30800e22811057fb30b0ec0be78ae