From eb5749e8d9e873ac5aec2ba042d7a04b894f1421 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 9 Jul 2013 11:39:13 -0700 Subject: Bugfix QDesktopServices on Windows It was doing tricks with URLs that it shouldn't be doing... including running QDir::toNativeSeparators on a URL. Task-number: QTBUG-32311 Change-Id: I5b6f640919956998c00dcf507f931045f21a9e53 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsservices.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index 250fea56b1..546957a043 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#define QT_NO_URL_CAST_FROM_STRING #include "qwindowsservices.h" #include "qtwindows_additional.h" @@ -55,19 +56,20 @@ QT_BEGIN_NAMESPACE enum { debug = 0 }; -static inline bool shellExecute(const QString &file) +static inline bool shellExecute(const QUrl &url) { #ifndef Q_OS_WINCE - const QString nativeFilePath = QDir::toNativeSeparators(file); + const QString nativeFilePath = + url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded); const quintptr result = (quintptr)ShellExecute(0, 0, (wchar_t*)nativeFilePath.utf16(), 0, 0, SW_SHOWNORMAL); // ShellExecute returns a value greater than 32 if successful if (result <= 32) { - qWarning("ShellExecute '%s' failed (error %s).", qPrintable(file), qPrintable(QString::number(result))); + qWarning("ShellExecute '%s' failed (error %s).", qPrintable(url.toString()), qPrintable(QString::number(result))); return false; } return true; #else - Q_UNUSED(file) + Q_UNUSED(url); return false; #endif } @@ -131,7 +133,7 @@ static inline bool launchMail(const QUrl &url) } // Pass the url as the parameter. Should use QProcess::startDetached(), // but that cannot handle a Windows command line [yet]. - command.replace(QStringLiteral("%1"), url.toString()); + command.replace(QStringLiteral("%1"), url.toString(QUrl::FullyEncoded)); if (debug) qDebug() << __FUNCTION__ << "Launching" << command; //start the process @@ -152,16 +154,14 @@ static inline bool launchMail(const QUrl &url) bool QWindowsServices::openUrl(const QUrl &url) { const QString scheme = url.scheme(); - if (scheme.isEmpty()) - return openDocument(url); if (scheme == QStringLiteral("mailto") && launchMail(url)) return true; - return shellExecute(QLatin1String(url.toEncoded())); + return shellExecute(url); } bool QWindowsServices::openDocument(const QUrl &url) { - return shellExecute(url.isLocalFile() ? url.toLocalFile() : url.toString()); + return shellExecute(url); } QT_END_NAMESPACE -- cgit v1.2.3