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 07b1e1c5fe and
7f49d93fc1

Change-Id: If2dd9e745d5d98615b851ee4315e7de9a75afb00
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2023-04-21 11:27:38 +02:00
parent 4acffc7cce
commit 54177ebccd

View File

@@ -1016,10 +1016,17 @@ void LocatorWidget::acceptEntry(int row)
const QModelIndex index = m_locatorModel->index(row, 0); const QModelIndex index = m_locatorModel->index(row, 0);
if (!index.isValid()) if (!index.isValid())
return; return;
const LocatorFilterEntry entry = m_locatorModel->data(index, LocatorEntryRole).value<LocatorFilterEntry>(); const LocatorFilterEntry entry
= m_locatorModel->data(index, LocatorEntryRole).value<LocatorFilterEntry>();
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(); QWidget *focusBeforeAccept = QApplication::focusWidget();
if (!entry.acceptor)
EditorManager::openEditor(entry);
const AcceptResult result = entry.acceptor ? entry.acceptor() : AcceptResult(); const AcceptResult result = entry.acceptor ? entry.acceptor() : AcceptResult();
if (result.newText.isEmpty()) { if (result.newText.isEmpty()) {
emit hidePopup(); emit hidePopup();