Bug 455671 - Dragging and dropping an image results in blank layer name
Summary: Dragging and dropping an image results in blank layer name
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: amyspark
URL:
Keywords:
: 456096 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-06-20 19:26 UTC by Freya Lupen
Modified: 2022-07-02 00:52 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Freya Lupen 2022-06-20 19:26:21 UTC
SUMMARY
***
Dragging-and-dropping an image as a paint layer causes the layer name to be blank.
***


STEPS TO REPRODUCE
1.  Drag and drop an image into an open document, choosing "Insert as New Layer".

OBSERVED RESULT
The resulting layer's name is blank.

EXPECTED RESULT
The resulting layer's name is the image's filename.


SOFTWARE/OS VERSIONS
Krita git 389448dd39

ADDITIONAL INFORMATION
I could be wrong, but it seems likely to be related to line 531 of libs/ui/KisView.cpp (changed in MR!1296):
KisPaintLayerSP layer = new KisPaintLayer(this->image(), "", OPACITY_OPAQUE_U8, clip);
The layer is initialized without a name and as far as I can tell is never given one, thus the bug.
Comment 1 amyspark 2022-06-20 21:35:27 UTC
One of the side effects of https://invent.kde.org/graphics/krita/-/merge_requests/1296 is that single layers are now consistently imported as paint devices, whether they were pasted from an image or from an URL. 

When an image is imported as a paint device, it only preserves the bitmap data, so the original file name is obviously lost upon return. On the other hand, multiple files are still handled via KisImageManager::importImage, which isn't affected.

Not sure how (or if) I should fix it, so cc'ing Halla and Dmitry for a decision.
Comment 2 amyspark 2022-06-20 21:36:00 UTC
(awaiting for answer)
Comment 3 vanyossi 2022-06-29 00:14:59 UTC
*** Bug 456096 has been marked as a duplicate of this bug. ***
Comment 4 vanyossi 2022-06-29 00:15:54 UTC
Can also confirm this as of git (df921a2426)
Comment 5 amyspark 2022-06-29 09:25:22 UTC
I've posted a partial fix in https://invent.kde.org/graphics/krita/-/merge_requests/1482, it'll set the name to "Paint layer X (pasted)" as is done currently with other actions. I'm not sure if we can set a custom property ("name") to a paint device yet.
Comment 6 David REVOY 2022-06-29 09:35:05 UTC
Thank you for the partial fix @amyspark, 
I understand it's a technical challenge here to get back the filename as a layer name, but getting it was super convenient for my workflow. 
eg. On my files, I have many texture already (file)named for this, like grids, perspective vanishing points, textures, photobash elements; ready to drag and drop.
Comment 7 amyspark 2022-07-02 00:50:21 UTC
Git commit 3706f1d50cd0b617f6180ae1425d001e47c8e26c by L. E. Segovia.
Committed on 02/07/2022 at 00:42.
Pushed by lsegovia into branch 'master'.

Give new single-layer pastes a default name

M  +5    -1    libs/ui/KisView.cpp

https://invent.kde.org/graphics/krita/commit/3706f1d50cd0b617f6180ae1425d001e47c8e26c
Comment 8 amyspark 2022-07-02 00:50:45 UTC
Git commit ad2bbd1f67d13c3deea35c1cdf29ac7fada2b1a7 by L. E. Segovia.
Committed on 02/07/2022 at 00:42.
Pushed by lsegovia into branch 'master'.

KisClipboard: decouple source selection and allow for manual import of single URLs

M  +153  -42   libs/ui/KisView.cpp
M  +43   -10   libs/ui/kis_clipboard.cc
M  +14   -6    libs/ui/kis_clipboard.h

https://invent.kde.org/graphics/krita/commit/ad2bbd1f67d13c3deea35c1cdf29ac7fada2b1a7
Comment 9 amyspark 2022-07-02 00:52:05 UTC
Git commit 057b6e89adb9c19f010d31dfc6aa9694401ae54e by L. E. Segovia.
Committed on 02/07/2022 at 00:51.
Pushed by lsegovia into branch 'krita/5.1'.

Give new single-layer pastes a default name
(cherry picked from commit 3706f1d50cd0b617f6180ae1425d001e47c8e26c)

M  +5    -1    libs/ui/KisView.cpp

https://invent.kde.org/graphics/krita/commit/057b6e89adb9c19f010d31dfc6aa9694401ae54e
Comment 10 amyspark 2022-07-02 00:52:13 UTC
Git commit 951a8211c4e98b6aa4d2c392378e9ca7e46203b0 by L. E. Segovia.
Committed on 02/07/2022 at 00:51.
Pushed by lsegovia into branch 'krita/5.1'.

KisClipboard: decouple source selection and allow for manual import of single URLs
(cherry picked from commit ad2bbd1f67d13c3deea35c1cdf29ac7fada2b1a7)

M  +153  -42   libs/ui/KisView.cpp
M  +43   -10   libs/ui/kis_clipboard.cc
M  +14   -6    libs/ui/kis_clipboard.h

https://invent.kde.org/graphics/krita/commit/951a8211c4e98b6aa4d2c392378e9ca7e46203b0