From 93ed05edfae16b6b26440e4b9965664c5c54b108 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 15 Dec 2023 21:50:47 +0100 Subject: [PATCH] QFileDialog/win: pass only filename to IFileDialog::SetFileName() When calling QFileDialog::selectFile(), the file is passed as QUrl to the underlying functions. Then this url was converted back to a local file and the full path (with wrong path separators on windows) was shown in the filename edit box in the native dialog. There was already a comment to use QUrl::fileName() but it did not exist when the code was written and later it was forgotten. Fixes: QTBUG-47159 Change-Id: I478dfd0e4943277c0ac78ebf4e138257e7ea8662 Reviewed-by: Axel Spoerl (cherry picked from commit 19c701d370512e81d1b934f899b03ae0c2e6953f) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 4938b234ad251c5b2480bb9e28b3482fb4425345) --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index eb9cfa73277..1c7ad0c1022 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1585,7 +1585,7 @@ void QWindowsFileDialogHelper::selectFile(const QUrl &fileName) qCDebug(lcQpaDialogs) << __FUNCTION__ << fileName.toString(); if (hasNativeDialog()) // Might be invoked from the QFileDialog constructor. - nativeFileDialog()->selectFile(fileName.toLocalFile()); // ## should use QUrl::fileName() once it exists + nativeFileDialog()->selectFile(fileName.fileName()); } QList QWindowsFileDialogHelper::selectedFiles() const