Bug 420051 - Reference Images disappear when using snapshots
Summary: Reference Images disappear when using snapshots
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tools/Reference Images (show other bugs)
Version: 4.2.8
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
: 423167 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-04-13 19:19 UTC by Bollebib
Modified: 2020-08-08 19:15 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bollebib 2020-04-13 19:19:09 UTC
Add a few reference images
make a bunch of compositions from a whole bunch of layers


cycle between the compositions by doubleclicking them

eventually the reference images will disappear till you restart the file
Comment 1 vanyossi 2020-04-24 01:50:51 UTC
I can reproduce this issue.

1. Create a new composition if there is none.
2. Add a reference image if there is none.
3. activate the composition (double click)
4. pan canvas.

RESULT:
Reference images dissapear.
Krita 4.2.9
Comment 2 vanyossi 2020-06-19 17:28:24 UTC
*** Bug 423167 has been marked as a duplicate of this bug. ***
Comment 3 wolthera 2020-08-07 16:25:31 UTC
Git commit ce8879455c7ce7eb02823e367d9da625fb240c2a by Wolthera van Hövell tot Westerflier.
Committed on 07/08/2020 at 16:25.
Pushed by woltherav into branch 'master'.

Fix skipping over fake nodes for composition visibility.

The compositions should not be handling anything related to fake
nodes, such as the ones where the reference layer and the
assistants/guides live one.
Related: bug 417911

M  +5    -0    libs/image/kis_layer_composition.cpp

https://invent.kde.org/graphics/krita/commit/ce8879455c7ce7eb02823e367d9da625fb240c2a
Comment 4 wolthera 2020-08-07 16:26:58 UTC
Git commit 0a0caa8594d2429ab36cc6fb8356fa8bd80d4362 by Wolthera van Hövell tot Westerflier.
Committed on 07/08/2020 at 16:26.
Pushed by woltherav into branch 'krita/4.3'.

Fix skipping over fake nodes for composition visibility.

The compositions should not be handling anything related to fake
nodes, such as the ones where the reference layer and the
assistants/guides live one.
Related: bug 417911

M  +5    -0    libs/image/kis_layer_composition.cpp

https://invent.kde.org/graphics/krita/commit/0a0caa8594d2429ab36cc6fb8356fa8bd80d4362
Comment 5 wolthera 2020-08-07 16:27:22 UTC
Ok, so there's still the snapshots issue.

This one is kinda hairy as it's all weak reference pointer copy implementation magic.

But generally, what is happening is that the reference layer gets copied, but the canvas decorations aren't updated (specifically,  KisReferenceImagesDecoration::setReferenceImageLayer(KisSharedPtr<KisReferenceImagesLayer> layer) needs to be called for the changing snapshot), and I am not sure where to do that...
Comment 6 tusooa 2020-08-08 10:04:22 UTC
(In reply to wolthera from comment #5)
> Ok, so there's still the snapshots issue.
> 
> This one is kinda hairy as it's all weak reference pointer copy
> implementation magic.
> 
> But generally, what is happening is that the reference layer gets copied,
> but the canvas decorations aren't updated (specifically, 
> KisReferenceImagesDecoration::
> setReferenceImageLayer(KisSharedPtr<KisReferenceImagesLayer> layer) needs to
> be called for the changing snapshot), and I am not sure where to do that...

Looks like I am able to fix the bug that the reference images are not shown, but the ref images cannot automatically update after a switch. This is probably due to tiar's fix of https://invent.kde.org/graphics/krita/-/commit/311d804aa23f1993ec19513cdd90ad0758627f3c because:

[1] d->layer->extent() is always QRectF() # I think this is problematic.
[2] slotReferenceImagesChanged() (i.e. the update canvas part) will not be run if extent is empty # tiar thinks extent == QRectF() implies the layer is not loaded yet. But this is not the case.
[3] As a result, slotReferenceImagesChanged() will never run.
Comment 7 tusooa 2020-08-08 18:36:51 UTC
The crash fixed by tiar is actually due to

[1] slotReferenceImagesLayerChanged() called when initializing KisView::Private::referenceImagesDecoration().
[2] At that time, KisView's d-pointer is not yet initialized (Private ctor has not yet return) (so there is a random value).
[3] KisView::viewConverter() makes use of its d-pointer.

So, it does not seem to be related to the extent being zero.
Comment 8 tusooa 2020-08-08 19:15:37 UTC
Git commit 29e666f94178daef0ba5551507d2e388faf45cf2 by Tusooa Zhu.
Committed on 08/08/2020 at 19:08.
Pushed by tusooaw into branch 'master'.

Fix ref images layer not shown after switching snapshot

[1] The fix for a crash when loading a file with ref images in
https://invent.kde.org/graphics/krita/-/commit/311d804aa23f1993ec19513cdd90ad0758627f3c
used layer->extent() as a criterion for judging whether "the layer is loaded."
However, this criterion is not correct because the real cause of the crash is
KisView's d-pointer is not yet initialized, when KisReferenceImagesDecoration
is being constructed, which is called by the ctor of KisView::Private.

[2] layer->extent() is always empty so the current situation is
KisReferenceImagesDecoration::setReferenceImageLayer() is never called,
due to the criterion in [1].

[3] This fix added an argument, viewReady, to the constructor of
KisReferenceImagesDecoration, so that when it is being called from
KisView::Private's constructor, it will not try to update the canvas
because that leads to problems.

[4] In setReferenceImageLayer, I also modified the logic to not
try to dereference a weak pointer before verifying its validity.
If I do not do so, it will trigger an assert.

M  +4    -2    libs/ui/KisDocument.cpp
M  +11   -7    libs/ui/KisReferenceImagesDecoration.cpp
M  +2    -2    libs/ui/KisReferenceImagesDecoration.h
M  +1    -1    libs/ui/KisView.cpp

https://invent.kde.org/graphics/krita/commit/29e666f94178daef0ba5551507d2e388faf45cf2