From 506fb9e166918b2133952928cabee0a478e32a14 Mon Sep 17 00:00:00 2001 From: con Date: Fri, 10 Dec 2010 14:49:06 +0100 Subject: [PATCH] Dropping project blocks other programs (like file explorer). We have to delay or drop event handling, so the Qt code that delivers the event can return control. The commit also prevents dropping another file while we are currently already handling a drop. Task-number: QTCREATORBUG-3344 --- src/plugins/coreplugin/mainwindow.cpp | 15 +++++++++++++-- src/plugins/coreplugin/mainwindow.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 37c3572ccd..898ec1a6b4 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -401,7 +401,7 @@ static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0) void MainWindow::dragEnterEvent(QDragEnterEvent *event) { - if (isDesktopFileManagerDrop(event->mimeData())) { + if (isDesktopFileManagerDrop(event->mimeData()) && m_filesToOpenDelayed.isEmpty()) { event->accept(); } else { event->ignore(); @@ -413,12 +413,23 @@ void MainWindow::dropEvent(QDropEvent *event) QStringList files; if (isDesktopFileManagerDrop(event->mimeData(), &files)) { event->accept(); - openFiles(files, ICore::SwitchMode); + m_filesToOpenDelayed.append(files); + QTimer::singleShot(50, this, SLOT(openDelayedFiles())); } else { event->ignore(); } } +void MainWindow::openDelayedFiles() +{ + if (m_filesToOpenDelayed.isEmpty()) + return; + activateWindow(); + raise(); + openFiles(m_filesToOpenDelayed, ICore::SwitchMode); + m_filesToOpenDelayed.clear(); +} + IContext *MainWindow::currentContextObject() const { return m_activeContext; diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index b5ec6c906b..c3a4b96281 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -161,6 +161,7 @@ private slots: void updateFocusWidget(QWidget *old, QWidget *now); void setSidebarVisible(bool visible); void destroyVersionDialog(); + void openDelayedFiles(); private: void updateContextObject(IContext *context); @@ -222,6 +223,8 @@ private: QToolButton *m_toggleSideBarButton; QColor m_overrideColor; + + QStringList m_filesToOpenDelayed; }; } // namespace Internal -- 2.11.0