Bug 176277 - dolphin should mount umounted device, if a file is dropped upon its icon in "Places"
Review Request #106072 - Created Aug. 18, 2012 and submitted
Mount unmounted devices, when a file is dropped upon it in places-panel.
Thanks for the patch, and sorry for the late reply! I think that automatic mounting of drop targets will be a big usability improvement :-) Your patch works fine and looks good in principle, but I'm wondering if we can avoid the nested event loop. The good thing about running an event loop inside slotItemDropEvent() is that it's an easy way to wait until the mounting is finished, but nested event loops (i.e., event loops which run inside functions that are called from the application's main event loop) can lead to very strange and subtle problems (see, e.g., my fix for bug 167810, which caused a very bad regression, bug 202176). Two possible problems that I can think of right now: 1. If mounting the device fails, Dolphin might freeze forever. 2. If mounting takes a few seconds, and the user clicks the close button of the Dolphin window before the nested event loop finishes, Dolphin will crash with a possibly ugly backtrace. But that it not obvious at all for someone who hasn't had this kind of trouble before! To prevent these problems, one could connect the model's storageSetupDone() signal to a new slot that does the actual dropping (i.e., calls DragAndDropHelper::dropUrls()), but then we need some intermediate storage for the index and the information in the QGraphicsSceneDragDropEvent. I don't see a way to do it without this kind of complexity and ugliness at the moment :-( But I really prefer to avoid nested event loops because of the bad experience we had with them.
Thanks, looks nice! It's a bit more complicated than your first approach, but IMHO that's better than risking crashes :-) I think that this is safe to commit to the 4.9 branch because the new code path is only taken in the case that the device is not mounted, such that the drag&drop operation fails currently. In the long term, one could think about possibilites to reduce code duplication, but this should include a review of all places where DragAndDropHelper is used and is not urgent at the moment.