Bug 491665

Summary: Crash when pasting content from clipboard after reopening Krita
Product: [Applications] krita Reporter: aivanjou84
Component: GeneralAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: penguinflyer2222
Priority: NOR    
Version: 5.2.3   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description aivanjou84 2024-08-13 13:08:47 UTC
SUMMARY
Krita crashes when pasting content from the clipboard after reopening the program.

STEPS TO REPRODUCE
1. Copy bitmap content or any layer to the clipboard.
2. Close Krita.
3. Reopen Krita.
4. Paste the clipboard content.

OBSERVED RESULT
Krita crashes.

EXPECTED RESULT
Krita should paste the content correctly, or at least not crash if the content cannot be pasted.

SOFTWARE/OS VERSIONS
Windows: Windows 11 Pro

ADDITIONAL INFORMATION
·The crash occurs when copying and pasting any type of layer (vector layer, paint layer, filter layer, group layer).
·Copying vector elements and text works as long as the content of the layer is copied and not the layer itself.
·In the case of bitmap content, it crashes even if only a selection is copied and not the entire layer.
·If the content is copied from a reference image using the Reference Images Tool, the content will be pasted as a paint layer without any issues.
Comment 1 Freya Lupen 2024-08-13 13:45:20 UTC
Confirmed on 5.2.3. On 5.3.x it safe asserts and pastes an empty layer instead, because of commit 8ae307a9.

The reason it can't paste a layer from a previous run is because it doesn't store the layer data itself, but a pointer to it, which is no longer valid when Krita is closed.
Comment 2 Halla Rempt 2024-09-03 12:23:03 UTC
Git commit ad17230749bc1e73a9365f9c2939445f91718971 by Halla Rempt, on behalf of Simon Ra.
Committed on 03/09/2024 at 12:22.
Pushed by rempt into branch 'krita/5.2'.

fix an assert that should have been a safe assert.

This is hit when pasting data from a previous session of krita (after
restarting it) because the layer data itself is not on the clipboard.
(cherry picked from commit 8ae307a9d8dfebb039742089dcb5680e182df2f6)

M  +1    -1    libs/ui/kis_clipboard.cc

https://invent.kde.org/graphics/krita/-/commit/ad17230749bc1e73a9365f9c2939445f91718971