Bug 408028

Summary: Objects on Duplicated Vector Layer can't be edited
Product: [Applications] krita Reporter: Ahab Greybeard <ahab.greybeard>
Component: Layers/VectorAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: halla, tamtamy.tymona, tusooa
Priority: NOR    
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: File to test Duplicated Vector Layer problem

Description Ahab Greybeard 2019-05-28 12:11:06 UTC
SUMMARY
This bug occurs in all versions from 4.1.7 onwards but seems worse in the 4.2.0 pre-alpha appimages and the latest 4.3.0 pre-alpha nightly build.

If a vector layer is Duplicated (not copy/pasted), the duplicated layer objects can't have their properties edited (in Tool Options, e.g. stroke and fill style) and if moved, the bounding box is moved but the on-screen image is not altered. After a Save and Open, this bug no longer happens.

STEPS TO REPRODUCE
See above

OBSERVED RESULT
See above

EXPECTED RESULT
It should be possible to edit selected vector shapes in a duplicated layer.

SOFTWARE/OS VERSIONS
Krita

 Version: 4.3.0-prealpha (git fc51481)
 Languages: en_GB, en
 Hidpi: true

Qt

  Version (compiled): 5.12.2
  Version (loaded): 5.12.2

ADDITIONAL INFORMATION
In 4.1.7, this bug could be cleared by turning off/on both the original and duplicated layer. Also, in 4.1.7, the vector object could be moved, after which the bug did not happen.
Comment 1 tusooa 2019-05-28 12:35:58 UTC
Can confirm this on master.

PS: "Duplicate" means "Duplicate Layer or Mask" in the layers docker context menu.
Comment 2 tusooa 2019-05-28 12:54:01 UTC
(In reply to tusooa from comment #1)
> Can confirm this on master.
> 
> PS: "Duplicate" means "Duplicate Layer or Mask" in the layers docker context
> menu.

Update: the display problem will disappear after some time, but movements afterwards
will still trigger the display problem.
Comment 3 Tiar 2019-06-03 09:05:35 UTC
Vector shapes are edited, just the preview is not updated.

If you try to save, the preview gets updated and the rectangle jumps to the correct location. If you open the image, it is also loaded in the correct location.
If you turn off and on the visibility of the layer, it doesn't work.
It you paint over the duplicated layer (for example on paint layer), trying to update it, and then turn off and on the visibility of the paint layer, it won't work either.
Comment 4 Dmitry Kazakov 2019-06-03 11:48:56 UTC
Git commit 05a6402935b61d6f2a0f0e964557a48a7c73a994 by Dmitry Kazakov.
Committed on 03/06/2019 at 11:48.
Pushed by dkazakov into branch 'master'.

Fix cloning vector layers

For all internal vector updates we should use safe signal
compressor instead of the regular one. Otherwise "timers
are accesses from non-gui thread" problem will chase us :)

M  +2    -1    libs/global/kis_signal_compressor.h
M  +6    -0    libs/global/kis_thread_safe_signal_compressor.cpp
M  +2    -0    libs/global/kis_thread_safe_signal_compressor.h
M  +1    -2    libs/ui/flake/kis_shape_layer_canvas.h

https://invent.kde.org/kde/krita/commit/05a6402935b61d6f2a0f0e964557a48a7c73a994
Comment 5 Ahab Greybeard 2019-06-03 17:12:06 UTC
krita-4.3.0-prealpha-b5e9fba-x86_64.appimage now has this problem partly fixed.

Moving any object in a duplicated vector layer now shows the move and there are no more problem with that layer.

However, if a layer is duplicated, objects in that layer can't have their fill and stroke properies edited (in the Options docker) until a manual move is done or until the Geometry is edited in the options docker. After editing Geometry, no matter if it's a tiny size change, the fill and stroke properties can then be edited.
Comment 6 Halla Rempt 2019-06-03 17:31:47 UTC
Let's reopen then
Comment 7 Halla Rempt 2019-06-03 17:32:06 UTC
And reassign
Comment 8 Halla Rempt 2019-06-04 15:21:30 UTC
Git commit ef3bff5eb29e235d9a5527d2f03765edf86aab8b by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 04/06/2019 at 15:19.
Pushed by rempt into branch 'krita/4.2'.

Fix cloning vector layers

For all internal vector updates we should use safe signal
compressor instead of the regular one. Otherwise "timers
are accesses from non-gui thread" problem will chase us :)

M  +2    -1    libs/global/kis_signal_compressor.h
M  +6    -0    libs/global/kis_thread_safe_signal_compressor.cpp
M  +2    -0    libs/global/kis_thread_safe_signal_compressor.h
M  +1    -2    libs/ui/flake/kis_shape_layer_canvas.h

https://invent.kde.org/kde/krita/commit/ef3bff5eb29e235d9a5527d2f03765edf86aab8b
Comment 9 Ahab Greybeard 2019-06-05 09:12:05 UTC
Created attachment 120593 [details]
File to test Duplicated Vector Layer problem

Commit ef3bff5eb29e235d9a5527d2f03765edf86aab8b is now in the latest Krita Stable Appimage krita-4.2.1-01440fb-x86_64.appimage Build #389 of June 4th.

It seems to be the same as Commit 05a6402935b61d6f2a0f0e964557a48a7c73a994 of June 3rd and does not fix the editing problem where the Stroke and Fill properties can't be changed.

I've attached a .kra file that I find useful for checking this.

The duplicated layer seems to be 'locked up' or 'frozen' and the smallest manual movement or Geometry edit will fix all the problems, even if Undo is used to revert the movement or the Geometry edit.
Comment 10 Halla Rempt 2019-06-05 11:32:33 UTC
I'll ask Dmitry.
Comment 11 tusooa 2019-06-09 08:56:51 UTC
The duplicated layer is shown on canvas. This is tested by making the source layer semi-transparent, and then duplicating that layer.

If one clicks "File->Create Copy From Current Image," the buggy behaviour in the copy will not happen.
Comment 12 Dmitry Kazakov 2019-06-15 05:51:16 UTC
Git commit 9cabfa26876cb4921dae2eccc5ec0a1cb5b7d54f by Dmitry Kazakov.
Committed on 15/06/2019 at 05:50.
Pushed by dkazakov into branch 'master'.

Fix availability of vectors on cloned vector layers (again)

KoSelection emits signals using signal compressor, which
is placed in the GUI thread (because of timers), therefore
it might receive queued signals. And for parsing queued
signals it needs an event loop...

So we just ensure that KoShapeManager and KoSelection belong
to the GUI thread, where an event loop is surely present.

M  +3    -3    libs/flake/KoSelection.cpp
M  +1    -1    libs/flake/KoSelection.h
M  +2    -2    libs/flake/KoSelection_p.h
M  +11   -0    libs/flake/KoShapeManager.cpp
M  +1    -1    libs/flake/KoShapeManager_p.h

https://invent.kde.org/kde/krita/commit/9cabfa26876cb4921dae2eccc5ec0a1cb5b7d54f
Comment 13 Halla Rempt 2019-06-17 08:18:08 UTC
Git commit b8e839f096ac9a453f66f6085150ac157ef46226 by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 17/06/2019 at 08:17.
Pushed by rempt into branch 'krita/4.2'.

Fix availability of vectors on cloned vector layers (again)

KoSelection emits signals using signal compressor, which
is placed in the GUI thread (because of timers), therefore
it might receive queued signals. And for parsing queued
signals it needs an event loop...

So we just ensure that KoShapeManager and KoSelection belong
to the GUI thread, where an event loop is surely present.

M  +3    -3    libs/flake/KoSelection.cpp
M  +1    -1    libs/flake/KoSelection.h
M  +2    -2    libs/flake/KoSelection_p.h
M  +11   -0    libs/flake/KoShapeManager.cpp
M  +1    -1    libs/flake/KoShapeManager_p.h

https://invent.kde.org/kde/krita/commit/b8e839f096ac9a453f66f6085150ac157ef46226