From 54177ebccd36d2548dd15e1d81c5f9844f6de278 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 21 Apr 2023 11:27:38 +0200 Subject: [PATCH] Locator: Fix opening of remote files Opening remote files can pop up a ssh prompt, and before that happens we need to hide the locator popup, which otherwise can stay on front of that ssh prompt window, preventing the user from entering their password and opening the file. Otherwise for example modal error dialogs could also be shown. So, delay the EditorManager::open call to after the popup is hidden. Amends 07b1e1c5fe03806f7c8d78e1ae72ebd38a1b9849 and 7f49d93fc1a1b90c7cda44ea0c31c8a7798fb1d3 Change-Id: If2dd9e745d5d98615b851ee4315e7de9a75afb00 Reviewed-by: Jarek Kobus --- src/plugins/coreplugin/locator/locatorwidget.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index cd98f8e5dd1..97ffcd8d4ba 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -1016,10 +1016,17 @@ void LocatorWidget::acceptEntry(int row) const QModelIndex index = m_locatorModel->index(row, 0); if (!index.isValid()) return; - const LocatorFilterEntry entry = m_locatorModel->data(index, LocatorEntryRole).value(); + const LocatorFilterEntry entry + = m_locatorModel->data(index, LocatorEntryRole).value(); + if (!entry.acceptor) { + // Opening editors can open dialogs (e.g. the ssh prompt, or showing erros), so delay until + // we have hidden the popup with emit hidePopup below and Qt actually processed that + QMetaObject::invokeMethod( + EditorManager::instance(), + [entry] { EditorManager::openEditor(entry); }, + Qt::QueuedConnection); + } QWidget *focusBeforeAccept = QApplication::focusWidget(); - if (!entry.acceptor) - EditorManager::openEditor(entry); const AcceptResult result = entry.acceptor ? entry.acceptor() : AcceptResult(); if (result.newText.isEmpty()) { emit hidePopup();