Windows QPA/File dialog: Avoid UI hangs caused by empty results

Typing in invalid URLs results in empty result lists.
Emit rejected() in this case.

Task-number: QTBUG-71785
Change-Id: Ia257b85a5c4370227f753752f6a473bbb3a054be
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Friedemann Kleint 2019-04-03 14:20:27 +02:00
parent 6fff899697
commit ab47587856

View File

@ -967,7 +967,9 @@ void QWindowsNativeFileDialogBase::doExec(HWND owner)
const HRESULT hr = m_fileDialog->Show(owner);
QWindowsDialogs::eatMouseMove();
qCDebug(lcQpaDialogs) << '<' << __FUNCTION__ << " returns " << hex << hr;
if (hr == S_OK) {
// Emit accepted() only if there is a result as otherwise UI hangs occur.
// For example, typing in invalid URLs results in empty result lists.
if (hr == S_OK && !m_data.selectedFiles().isEmpty()) {
emit accepted();
} else {
emit rejected();