Bug 424697

Summary: Snapshots: crash when switching to snapshot with assistant, when there are no assistants currently
Product: [Applications] krita Reporter: Nabil Maghfur usman <nmaghfurusman>
Component: Tool/AssistantsAssignee: Nabil Maghfur usman <nmaghfurusman>
Status: RESOLVED FIXED    
Severity: normal CC: ghevan, tamtamy.tymona
Priority: NOR    
Version: 4.3.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: backtrace of thread #0 from gdb

Description Nabil Maghfur usman 2020-07-26 21:55:06 UTC
SUMMARY
When there are no assistants present on the document, Krita will crash when the user attempts to switch to a previous snapshot of the document that has assistants.

Besides this hiccup, snapshots do otherwise work correctly with assistants, so as a workaround, the user needs to have at least one assistant present on the canvas before attempting to revert to a snapshot that has assistants to achieve the expected result.

STEPS TO REPRODUCE
1. Create new document
2. Add Vanishing Point assistant
3. Create new snapshot in Snapshot Docker
4. Delete Vanishing Point assistant
5. Switch to snapshot in Snapshot Docker

OBSERVED RESULT
Krita crashes

EXPECTED RESULT
Revert document state to snapshot with Vanishing Point present on the canvas

Krita
  Version: 4.3.0

Qt
  Version (compiled): 5.12.8
  Version (loaded): 5.12.8

OS Information
  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 5.6.0-2-amd64
  Pretty Productname: Debian GNU/Linux bullseye/sid
  Product Type: debian
  Product Version: unknown


OpenGL Info
 
  Vendor:  "Intel Open Source Technology Center" 
  Renderer:  "Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)" 
  Version:  "3.0 Mesa 20.1.1" 
  Shading language:  "1.30" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:    QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile) 
     Version: 3.0
     Supports deprecated functions true 
     is OpenGL ES: false 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsOpenGLES: true 
  isQtPreferOpenGLES: false 

Hardware Information
 Memory: 7 Gb
 Cores: 8
 Swap: /tmp
Comment 1 Nabil Maghfur usman 2020-07-26 22:10:00 UTC
Created attachment 130421 [details]
backtrace of thread #0 from gdb

Strangely the backtrace doesn't seem to mention any of the assistant source files. I thought the crash would at least have something to do with canvas decorations, but haven't found any references to such things by glancing.

#0  KisNodeDummy::node (this=this@entry=0x0) at /home/nabil/Builds/kra/src/libs/ui/flake/kis_node_dummies_graph.cpp:84
No locals.
#1  0x00007ffff6e51848 in KisNodeDummiesGraph::unmapDummyRecursively (this=0x55555c019e18, dummy=0x0) at /home/nabil/Builds/kra/src/libs/ui/flake/kis_node_dummies_graph.cpp:172
        child = <optimized out>
#2  0x00007ffff6e51965 in KisNodeDummiesGraph::removeNode (this=this@entry=0x55555c019e18, node=<optimized out>, node@entry=0x0) at /home/nabil/Builds/kra/src/libs/ui/flake/kis_node_dummies_graph.cpp:157
        parent = <optimized out>
#3  0x00007ffff6e574e8 in KisNodeShapesGraph::removeNode (this=0x55555c019e18, node=...) at /home/nabil/Builds/kra/src/libs/ui/flake/kis_node_shapes_graph.cpp:62
        nodeDummy = 0x0
        tempShape = <optimized out>
[...]
Comment 2 Tiar 2020-07-27 17:24:35 UTC

*** This bug has been marked as a duplicate of bug 422428 ***
Comment 3 Dmitry Kazakov 2020-09-11 20:30:54 UTC
Git commit 945bfad224b0c562dd81b57673fffb8e060855e4 by Dmitry Kazakov.
Committed on 11/09/2020 at 20:30.
Pushed by dkazakov into branch 'krita/4.3'.

Fix a crash when recoverng the assistants via snapshots

Resetting the document via snapshots will add the fake decorations
layer itself, therefore we shouldn't try to execute
syncDecorationsWrapperLayerState() before the actual layers are cloned.
Related: bug 422428

M  +2    -0    libs/ui/KisDecorationsManager.cpp
M  +8    -1    libs/ui/KisDocument.cpp
M  +9    -0    libs/ui/kis_painting_assistants_decoration.cpp
M  +2    -0    libs/ui/kis_painting_assistants_decoration.h

https://invent.kde.org/graphics/krita/commit/945bfad224b0c562dd81b57673fffb8e060855e4
Comment 4 Dmitry Kazakov 2020-09-11 20:31:03 UTC
Git commit 69d20279e1ff085ad4d113972746f33d1b71e63f by Dmitry Kazakov.
Committed on 11/09/2020 at 20:30.
Pushed by dkazakov into branch 'krita/4.3'.

Fix updates of reference images when a snapshot is restored

M  +13   -6    libs/ui/KisDocument.cpp
M  +11   -4    libs/ui/KisReferenceImagesDecoration.cpp

https://invent.kde.org/graphics/krita/commit/69d20279e1ff085ad4d113972746f33d1b71e63f
Comment 5 Dmitry Kazakov 2020-09-11 20:41:09 UTC
Git commit cd4180b205e0077ec511cc02a73b42cec4ee85f2 by Dmitry Kazakov.
Committed on 11/09/2020 at 20:31.
Pushed by dkazakov into branch 'master'.

Fix a crash when recoverng the assistants via snapshots

Resetting the document via snapshots will add the fake decorations
layer itself, therefore we shouldn't try to execute
syncDecorationsWrapperLayerState() before the actual layers are cloned.
Related: bug 422428

M  +2    -0    libs/ui/KisDecorationsManager.cpp
M  +8    -1    libs/ui/KisDocument.cpp
M  +9    -0    libs/ui/kis_painting_assistants_decoration.cpp
M  +2    -0    libs/ui/kis_painting_assistants_decoration.h

https://invent.kde.org/graphics/krita/commit/cd4180b205e0077ec511cc02a73b42cec4ee85f2
Comment 6 Dmitry Kazakov 2020-09-11 20:41:14 UTC
Git commit 537b44d46a163e5fd26b198ff6d5473f968aa5cb by Dmitry Kazakov.
Committed on 11/09/2020 at 20:34.
Pushed by dkazakov into branch 'master'.

Fix updates of reference images when a snapshot is restored

# Conflicts:
#	libs/ui/KisReferenceImagesDecoration.cpp

M  +13   -6    libs/ui/KisDocument.cpp
M  +14   -8    libs/ui/KisReferenceImagesDecoration.cpp

https://invent.kde.org/graphics/krita/commit/537b44d46a163e5fd26b198ff6d5473f968aa5cb