summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-04-10 17:33:14 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2019-04-10 17:33:14 +0000
commit63e88f60a769f2535945db0e1cabb9815ff45a77 (patch)
treecea2359bc9b5b4e3acce7aeca59a2f9b5d251bcb /src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
parent0bdded64accc3f654b2d12d9bfaf64f842cedf26 (diff)
parentff88e20b8328b6aad5b787aacc5c39da563a67b1 (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" into refs/staging/5.13
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsdialoghelpers.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index ba441a1921..9de3268fc8 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -1453,26 +1453,41 @@ static QString createTemporaryItemCopy(QWindowsShellItem &qItem, QString *errorM
return result;
}
+static QUrl itemToDialogUrl(QWindowsShellItem &qItem, QString *errorMessage)
+{
+ QUrl url = qItem.url();
+ if (url.isLocalFile() || url.scheme().startsWith(QLatin1String("http")))
+ return url;
+ const QString path = qItem.path();
+ if (path.isEmpty() && !qItem.isDir() && qItem.canStream()) {
+ const QString temporaryCopy = createTemporaryItemCopy(qItem, errorMessage);
+ if (temporaryCopy.isEmpty()) {
+ QDebug(errorMessage).noquote() << "Unable to create a local copy of"
+ << qItem << ": " << errorMessage;
+ return QUrl();
+ }
+ return QUrl::fromLocalFile(temporaryCopy);
+ }
+ if (!url.isValid())
+ QDebug(errorMessage).noquote() << "Invalid URL obtained from" << qItem;
+ return url;
+}
+
QList<QUrl> QWindowsNativeOpenFileDialog::dialogResult() const
{
QList<QUrl> result;
IShellItemArray *items = nullptr;
if (SUCCEEDED(openFileDialog()->GetResults(&items)) && items) {
+ QString errorMessage;
for (IShellItem *item : QWindowsShellItem::itemsFromItemArray(items)) {
QWindowsShellItem qItem(item);
- const QString path = qItem.path();
- if (path.isEmpty() && !qItem.isDir()) {
- QString errorMessage;
- const QString temporaryCopy = createTemporaryItemCopy(qItem, &errorMessage);
- if (temporaryCopy.isEmpty()) {
- qWarning().noquote() << "Unable to create a local copy of" << qItem
- << ": " << errorMessage;
- } else {
- result.append(QUrl::fromLocalFile(temporaryCopy));
- }
- } else {
- result.append(qItem.url());
+ const QUrl url = itemToDialogUrl(qItem, &errorMessage);
+ if (!url.isValid()) {
+ qWarning("%s", qPrintable(errorMessage));
+ result.clear();
+ break;
}
+ result.append(url);
}
}
return result;