Commit 506fb9e1 authored by con's avatar con

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
parent 34019eaf
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment