Don't crash when dropping items in the dropdown menu that appears when hovering an arrow in the location bar (breadcrumb mode)

Review Request #111273 - Created June 27, 2013 and submitted

Frank Reininghaus
192139, 256338, 293220
First of all, note that dropping items on these dropdown menus is apparently currently not possible when using the Oxygen style, see

Dropping items on the dropdown menu that appears when hovering an arrow in the location bar may cause a crash if the "File exists" dialog appears.

The cause of the crash is that everything that is triggered by dropping anything on the menu happens inside the menu's nested event loop. However, when the "File exists" dialog appears, the menu loses focus and is probably deleted, so bad things can happen as soon as the nested event loop quits.

The fix is to make the action triggered by the drop delayed. It's a bit harder than it seems at first sight though: just making the connection to the KUrlNavigator's signal delayed with the Qt::QueuedConnection argument does not work because the QDropEvent pointer becomes dangling as soon as the drop is finished. So we have to copy the drop event, which is also a bit difficult because neither the QDropEvent nor QMimeData have a copy constructor or assignment operator. This is why I propose this solution which looks a bit too complicated at first sight - I just couldn't find an easier way to make it work.
No crashes any more. One problem is that the drop down menu does not disappear after the drop unless the "File exists" dialog appears, but I think that this must be fixed in KUrlNavigator. I'll have a look.
Emmanuel Pescosta
Commit Hook
This review has been submitted with commit 669ee3250d233b96bc2f2e63865b048d33215674 by Frank Reininghaus to branch master.
Frank Reininghaus
Review request changed

Status: Closed (submitted)