Bug 400357

Summary: [layer-stack] Renaming layers has not a consistent usability
Product: [Applications] krita Reporter: David REVOY <info>
Component: UsabilityAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: freebox64, griffinvalley, halla, kstgear, loentar
Priority: NOR Keywords: triaged
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: (Video)
Video example 2 (timing)
Disable updating layer name upon thumbnail update

Description David REVOY 2018-10-27 07:59:38 UTC
Hi,
Here is a bug about renaming layer (not a new behavior).

To reproduce:
=============
1. Create a new document
2. Create three or four new layers (eg. Layer 1, Layer 2, Layer 3)
3. Double click the name of the layer to edit it (can be with mouse or stylus)

Result:
=======
Sometime a double-click highlights the full layer name (perfect).
But sometime the highlight disappear and cursor jumps at the end of the name. Sometime the double-click select only the last word (eg. "2" in "Layer 2"). Sometime, the highlight select all the name, but as soon as I type, the cursor jumps to the last position. This issue results in having often mis named layers or having to edit more than one or two time until I can set a correct name.
Comment 1 mvowada 2018-10-27 13:14:34 UTC
Created attachment 115919 [details]
(Video)

(Krita appimage 4.2.0-pre-alpha (git 55c0c6d) - Ubuntu 14.04, Unity)

Hi, here I can reproduce the issue with these steps (see video):

    1. click on any layer once
    2. double click the actual layer you need to rename.

Actual Results: text highlighting disappears after a second
Comment 2 mvowada 2018-10-27 13:15:19 UTC
Confirming.
Comment 3 mvowada 2018-10-27 13:21:27 UTC
The exact steps are:

    1. click on "layer A", once
    2. double click on "layer B" (it works)
    3. click on "layer A" once
    4. double click on "layer B"
Comment 4 wolthera 2018-10-27 16:27:16 UTC
confirmed here too.
Comment 5 Halla Rempt 2018-10-30 13:29:21 UTC
I don't really this happening, but maybe that's because I'm using an external mouse, or a different xcb implementation, or something else. I'm not sure what we can do about it. If there's a fix, it probably will be in KisNodeDelegate::editorEvent
Comment 6 Halla Rempt 2018-10-30 13:40:22 UTC
Git commit dd0a38e89d8996b524d517710c3f903e4d240d18 by Boudewijn Rempt.
Committed on 30/10/2018 at 13:26.
Pushed by rempt into branch 'master'.

Give the delegate StrongFocus, as per Qt documentation

See http://doc.qt.io/qt-5/qabstractitemdelegate.html#createEditor

M  +2    -1    libs/ui/KisNodeDelegate.cpp

https://commits.kde.org/krita/dd0a38e89d8996b524d517710c3f903e4d240d18
Comment 7 wolthera 2018-10-30 19:04:55 UTC
I still get this issue here on git 9697760 :|
Comment 8 Halla Rempt 2018-11-20 08:58:34 UTC
Git commit 078429964d4fbb897b42374959e22961403bb42d by Boudewijn Rempt.
Committed on 20/11/2018 at 08:25.
Pushed by rempt into branch 'krita/4.1'.

Give the delegate StrongFocus, as per Qt documentation

See http://doc.qt.io/qt-5/qabstractitemdelegate.html#createEditor

M  +2    -1    libs/ui/KisNodeDelegate.cpp

https://commits.kde.org/krita/078429964d4fbb897b42374959e22961403bb42d
Comment 9 mvowada 2019-03-11 11:27:09 UTC
Created attachment 118713 [details]
Video example 2 (timing)

(Checked with Krita 4.2.0-pre-alpha (git c2fbec1)

Hi, could be a timing issue (see video)? 

If I do click the layer and quickly hit F2, then the text will lose its selection/highlighting. 

Where if I click the layer, wait a few seconds and hit F2, then the text will remain highlighted/selected.
Comment 10 Halla Rempt 2019-04-04 12:09:42 UTC
*** Bug 405334 has been marked as a duplicate of this bug. ***
Comment 11 Halla Rempt 2019-04-04 12:11:22 UTC
*** Bug 405310 has been marked as a duplicate of this bug. ***
Comment 12 Dmitrii Utkin 2019-05-25 20:30:07 UTC
Created attachment 120311 [details]
Disable updating layer name upon thumbnail update

I had some debug session today and found the reason of the bug. It comes from the timer which updates the thumbnail which drops to "LayerBox::updateThumbnail()" -> "NodeView::updateNode()" -> "NodeView::dataChanged(...)" -> "NodeDelegate::setEditorData(...)". 

There is no reason to update layer name in edit box every time when that signal is emitted, actually, it's sufficient enough to update it for the first time only when the layer name is to be put to the editbox, because of the second and further signals are came from "updateThumbnail".

I didn't find an other simple way to fix it, but this patch works reliable enough and do not revert layer name any more.

Please consider this patch, it fixes the bug, but I'm not sure if it is the correct way to go.
Comment 13 wolthera 2019-05-26 19:52:56 UTC
Hey Dmitry,

Would you like to try applying that patch to a fork of yours on the KDE gitlab instance(and then make a merge request)? https://invent.kde.org/kde/krita

If you don't, that's okay, it'll just make code review a little easier for us :)
Comment 14 Dmitrii Utkin 2019-05-26 19:58:51 UTC
Dear @wolthera, I'd like to create a fork and Merge Request, but could you please help me with login to gitlab?

Looks like it should use the same account as here, but I cannot login with it: "Invalid credentials". I tried with "KDE identity" and "Standard" options.
Comment 15 wolthera 2019-05-27 07:50:22 UTC
Hey Dmitry, did you make a KDE Identity account? At identity.kde.org? (It's a seperate login than the bugtracker, but on the plus side, basically every other KDE infra(forums, wikis, gitlab) except the bugtracker can use it)
Comment 16 Dmitrii Utkin 2019-05-27 18:15:23 UTC
Thanks for help, I managed to create the account. Here is the MR:

https://invent.kde.org/kde/krita/merge_requests/33
Comment 17 Halla Rempt 2019-06-05 07:35:12 UTC
Fixed in 

commit 98d97d0e7f900ad8be59faa0dc33e84648feda53
Author: Dmitrii Utkin <dmitriiutkin@kde.org>
Date:   Mon May 27 18:11:20 2019 +0000

    400357 don't update editor's text by setEditorData
Comment 18 David REVOY 2019-06-05 11:51:05 UTC
Thank you @Dmitry Utkin for fixing this bug and to @Boud too for shipping it with Krita 4.2.1 today. Super!