Bug 454515

Summary: Normal Copy/Cut/Paste behaves oddly when working with reference images
Product: [Applications] krita Reporter: acc4commissions
Component: Tools/Reference ImagesAssignee: amyspark <amy>
Status: RESOLVED FIXED    
Severity: normal CC: halla
Priority: NOR    
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: All   
Latest Commit: Version Fixed In:

Description acc4commissions 2022-05-28 05:41:26 UTC
SUMMARY
git 415b1a8 (it happened in git 0c31a5b too, and possibly in others as well.)

Copying/Cutting and Pasting gets really messy and behave unexpectedly when working with reference images. There are variety of symptoms(such as : not being able to copy the entire selection, sometimes the pasting being not working at all etc) but I can't reproduce everything all the time. 

One example tho :

STEPS TO REPRODUCE
1. Draw something in the canvas and import a reference image.
2. Copy or cut reference image
3. Select Freehand Selection Tool and select the drawing on the canvas. 
4. Try to copy paste it via shortcuts or whatever works.

OBSERVED RESULT
Krita paste reference images on the canvas, not the selected drawing.

EXPECTED RESULT
It should paste the drawing.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Halla Rempt 2022-06-24 13:49:55 UTC
Amyspark, please take a look.
Comment 2 amyspark 2022-06-24 16:04:01 UTC
Regression occurred in https://invent.kde.org/graphics/krita/-/commit/7b62b5c4c16e5832c1c1b842d4bbc493098e0827.

When a reference image is present, it will always ask the current tool to handle the copy. In this case, the code will ask the current tool to handle it, which is a no-op in almost every case.
Comment 3 amyspark 2022-06-24 16:05:47 UTC
> When a reference image is present, it will always ask the current tool to handle the copy. In this case, the code will ask the current tool to handle it, which is a no-op in almost every case.

Grammar mishap... 

When a reference image is present, it will always ask the current tool to handle the copy. This will result in the KoToolBase no-op in almost every case.
Comment 4 Bug Janitor Service 2022-06-24 17:06:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1488
Comment 5 amyspark 2022-06-27 21:18:41 UTC
Git commit df76bd6ccc5e3c450dcf81612e28f4598c397c73 by L. E. Segovia.
Committed on 27/06/2022 at 21:18.
Pushed by lsegovia into branch 'master'.

Implement Reference Tool selection detection

While commit 6e8224c52025fa1bf8508c3d4a2f98ecd4964019 implemented the
correct logic, it is only valid if the current tool is the Reference
Image tool.

There's a method for just this purpose, KoToolBase::hasSelection(), but
the existing flow stems from SelectionHandler::hasSelection, which
operates only with shapes. So this commit implements the
corresponding override and changes the check to query the current tool
instead.

CCMAIL: shzam@sdf.org

M  +5    -6    libs/ui/actions/kis_selection_action_factories.cpp
M  +6    -0    plugins/tools/defaulttool/referenceimagestool/ToolReferenceImages.cpp
M  +2    -0    plugins/tools/defaulttool/referenceimagestool/ToolReferenceImages.h

https://invent.kde.org/graphics/krita/commit/df76bd6ccc5e3c450dcf81612e28f4598c397c73
Comment 6 amyspark 2022-06-27 21:19:16 UTC
Git commit f7aac6fe2c6e1d0b5a96b9e31feb9e07e9edcc69 by L. E. Segovia.
Committed on 27/06/2022 at 21:19.
Pushed by lsegovia into branch 'krita/5.1'.

Implement Reference Tool selection detection

While commit 6e8224c52025fa1bf8508c3d4a2f98ecd4964019 implemented the
correct logic, it is only valid if the current tool is the Reference
Image tool.

There's a method for just this purpose, KoToolBase::hasSelection(), but
the existing flow stems from SelectionHandler::hasSelection, which
operates only with shapes. So this commit implements the
corresponding override and changes the check to query the current tool
instead.

CCMAIL: shzam@sdf.org
(cherry picked from commit df76bd6ccc5e3c450dcf81612e28f4598c397c73)

M  +5    -6    libs/ui/actions/kis_selection_action_factories.cpp
M  +6    -0    plugins/tools/defaulttool/referenceimagestool/ToolReferenceImages.cpp
M  +2    -0    plugins/tools/defaulttool/referenceimagestool/ToolReferenceImages.h

https://invent.kde.org/graphics/krita/commit/f7aac6fe2c6e1d0b5a96b9e31feb9e07e9edcc69