Bug 403685

Summary: Cannot drag and drop a file from file manager into Krita, under certain conditions
Product: [Applications] krita Reporter: Tyson Tan <tysontanx>
Component: GeneralAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: halla, postrowski5
Priority: NOR Keywords: regression, release_blocker, triaged
Version First Reported In: 4.1.7   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Tyson Tan 2019-01-28 12:20:55 UTC
SUMMARY
Under certain conditions, I cannot drag and drop a file from file manager into Krita. 

This issue does not affect the appimage version hosted on krita.org, but it happens to distro-distrubuted Krita. 

If I recall correctly, it happens under both Gnome and KDE Plasma. But I can only report this issue with detailed information under KDE Plasma at the moment.

STEPS TO REPRODUCE
1. Manjaro 18.0.2 KDE; 
2. KDE Plasma 5.14.5; Frameworks 5.54.0; At 5.12.0;
3. Dolphin 18.12.1;
4. Krita 4.1.7.101 from Manjaro's official repository;
5. PC has multiple screens; 
6. Krita and Dolphin must be placed on different screens; 
7. Krita has a document already opened in its window;
8. Drag and drop a file from Dolphin into Krita

OBSERVED RESULT
Nothing happened.

EXPECTED RESULT
Krita shows a menu to handle the dragged-in document.
Comment 1 Halla Rempt 2019-04-03 07:54:40 UTC
I cannot even drop on an open document if the pc doesn't have multiple screens. I suspect that this is yet another Qt 5.12 bug...
Comment 2 Halla Rempt 2019-04-03 09:13:52 UTC
I think so, I rebuilt the 4.0 branch with Qt 5.12, and there is no drop event happening whatsoever.
Comment 3 Halla Rempt 2019-04-03 09:14:10 UTC
*** Bug 406068 has been marked as a duplicate of this bug. ***
Comment 4 Halla Rempt 2019-04-03 09:17:01 UTC
To summarize the D&D problems I've found after building 4.0 and master with Qt 5.12 (I tested D&D using the mouse, not the stylus):

* Windows
** Dropping on the layerbox, or any other part of the UI except for the Palette docker opens the image in a new window, instead of showing the drop menu or opening the image as a layer (which would be logical for the layerbox)
** Dropping on the canvas works most of the time, but Qt shows the copy (+) icon on the cursor, which is wrong
** D&D on the welcome page

* Linux

** D&D on the welcome page works
** D&D on the canvas never works, added debug messages don't fire, so the dropEvent isn't called
** D&D on the rest of Krita works as on Windows

* macOS

** Not tested yet.
Comment 5 Halla Rempt 2019-04-03 09:24:55 UTC
Ah, known bug in Qt: https://codereview.qt-project.org/#/c/249086/

This explains why it works on Windows, where we use 5.12.2, but not on my Linux system, where I still have 5.12.0.  

However, it is still broken with the appimage, which uses Qt 5.12.2 -- so the fix might not be complete.
Comment 6 Halla Rempt 2019-04-03 09:32:13 UTC
Another note: that bug report and commit suggest that the issue only appears when QDragMoveevent isn't handled; however, KisView does handle that through QDragEnterEvent::QDragMoveEvent.
Comment 7 Halla Rempt 2019-04-03 12:20:28 UTC
Git commit bdb986129dc09df3e26e3bb9c5a8f63d4b3255dd by Boudewijn Rempt.
Committed on 03/04/2019 at 12:20.
Pushed by rempt into branch 'master'.

Work around problems with D&D in Qt 5.12

There are still some timing issues when dragging onto an existing
canvas, but we can't do much about that :-(

M  +2    -37   libs/ui/KisMainWindow.cpp
M  +5    -5    libs/ui/KisMainWindow.h
M  +15   -0    libs/ui/KisView.cpp
M  +4    -2    libs/ui/KisView.h
M  +55   -0    libs/ui/KisWelcomePageWidget.cpp
M  +8    -0    libs/ui/KisWelcomePageWidget.h

https://commits.kde.org/krita/bdb986129dc09df3e26e3bb9c5a8f63d4b3255dd
Comment 8 Tyson Tan 2019-04-03 14:51:08 UTC
Yeah, I guessed Qt too. I'm glad you've found a solution! Thank you Boud! :D