diff options
author | Liang Qi <liang.qi@qt.io> | 2016-04-27 09:18:05 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-04-27 09:18:05 +0200 |
commit | 23a36fd2bfcdb57849deaa1e10e6e3f7b1156ed8 (patch) | |
tree | b527c7e3ba4a831b542b0bccfb6a5a748a8a4fd9 /src/corelib | |
parent | c003a18ee332abf2387172eb0856a176a32a6c8f (diff) | |
parent | 072f5b513e486e884ea7fa4a1cac9aedf3846374 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/corelib/io/qprocess_win.cpp
src/widgets/itemviews/qheaderview.cpp
Change-Id: I0a59ade9cd6e91f770fdf298a7d72a41e79fd761
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qlogging.cpp | 9 | ||||
-rw-r--r-- | src/corelib/io/qlockfile_unix.cpp | 12 | ||||
-rw-r--r-- | src/corelib/io/qloggingregistry.cpp | 3 | ||||
-rw-r--r-- | src/corelib/io/qprocess_win.cpp | 40 | ||||
-rw-r--r-- | src/corelib/mimetypes/qmimedatabase.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 3 |
6 files changed, 57 insertions, 12 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index de37731b1a..4851d1ce6f 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -988,15 +988,18 @@ struct QMessagePattern { #endif #ifdef QLOGGING_HAVE_BACKTRACE struct BacktraceParams { - QString backtraceSeparator; - int backtraceDepth; + QString backtraceSeparator; + int backtraceDepth; }; - QList<BacktraceParams> backtraceArgs; // backtrace argumens in sequence of %{backtrace + QVector<BacktraceParams> backtraceArgs; // backtrace argumens in sequence of %{backtrace #endif bool fromEnvironment; static QBasicMutex mutex; }; +#ifdef QLOGGING_HAVE_BACKTRACE +Q_DECLARE_TYPEINFO(QMessagePattern::BacktraceParams, Q_MOVABLE_TYPE); +#endif QBasicMutex QMessagePattern::mutex; diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 7255414bdc..03dc5fc660 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -151,12 +151,14 @@ static bool fcntlWorksAfterFlock(const QString &fn) if (fcntlOK.isDestroyed()) return QLockFilePrivate::checkFcntlWorksAfterFlock(fn); bool *worksPtr = fcntlOK->object(fn); - if (!worksPtr) { - worksPtr = new bool(QLockFilePrivate::checkFcntlWorksAfterFlock(fn)); - fcntlOK->insert(fn, worksPtr); - } + if (worksPtr) + return *worksPtr; + + const bool val = QLockFilePrivate::checkFcntlWorksAfterFlock(fn); + worksPtr = new bool(val); + fcntlOK->insert(fn, worksPtr); - return *worksPtr; + return val; } static bool setNativeLocks(const QString &fileName, int fd) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 818772a399..eaebbc1ffc 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -365,9 +365,6 @@ void QLoggingRegistry::setApiRules(const QString &content) */ void QLoggingRegistry::updateRules() { - if (categoryFilter != defaultCategoryFilter) - return; - rules = qtConfigRules + configRules + apiRules + envRules; for (auto it = categories.keyBegin(), end = categories.keyEnd(); it != end; ++it) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 5d8b567c8c..ed540f9e5b 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -49,6 +49,7 @@ #include <qfileinfo.h> #include <qregexp.h> #include <qwineventnotifier.h> +#include <private/qsystemlibrary_p.h> #include <private/qthread_p.h> #include <qdebug.h> @@ -817,8 +818,45 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen) return stdinChannel.writer->write(data, maxlen); } +// Use ShellExecuteEx() to trigger an UAC prompt when CreateProcess()fails +// with ERROR_ELEVATION_REQUIRED. +static bool startDetachedUacPrompt(const QString &programIn, const QStringList &arguments, + const QString &workingDir, qint64 *pid) +{ + typedef BOOL (WINAPI *ShellExecuteExType)(SHELLEXECUTEINFOW *); + + static const ShellExecuteExType shellExecuteEx = // XP ServicePack 1 onwards. + reinterpret_cast<ShellExecuteExType>(QSystemLibrary::resolve(QLatin1String("shell32"), + "ShellExecuteExW")); + if (!shellExecuteEx) + return false; + + const QString args = qt_create_commandline(QString(), arguments); // needs arguments only + SHELLEXECUTEINFOW shellExecuteExInfo; + memset(&shellExecuteExInfo, 0, sizeof(SHELLEXECUTEINFOW)); + shellExecuteExInfo.cbSize = sizeof(SHELLEXECUTEINFOW); + shellExecuteExInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_UNICODE | SEE_MASK_FLAG_NO_UI; + shellExecuteExInfo.lpVerb = L"runas"; + const QString program = QDir::toNativeSeparators(programIn); + shellExecuteExInfo.lpFile = reinterpret_cast<LPCWSTR>(program.utf16()); + if (!args.isEmpty()) + shellExecuteExInfo.lpParameters = reinterpret_cast<LPCWSTR>(args.utf16()); + if (!workingDir.isEmpty()) + shellExecuteExInfo.lpDirectory = reinterpret_cast<LPCWSTR>(workingDir.utf16()); + shellExecuteExInfo.nShow = SW_SHOWNORMAL; + + if (!shellExecuteEx(&shellExecuteExInfo)) + return false; + if (pid) + *pid = qint64(GetProcessId(shellExecuteExInfo.hProcess)); + CloseHandle(shellExecuteExInfo.hProcess); + return true; +} + bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDir, qint64 *pid) { + static const DWORD errorElevationRequired = 740; + QString args = qt_create_commandline(program, arguments); bool success = false; PROCESS_INFORMATION pinfo; @@ -838,6 +876,8 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a CloseHandle(pinfo.hProcess); if (pid) *pid = pinfo.dwProcessId; + } else if (GetLastError() == errorElevationRequired) { + success = startDetachedUacPrompt(program, arguments, workingDir, pid); } return success; diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index bff6a9ac15..d866d3bcf7 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -520,7 +520,7 @@ QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const return mimeTypeForFile(url.toLocalFile()); const QString scheme = url.scheme(); - if (scheme.startsWith(QLatin1String("http"))) + if (scheme.startsWith(QLatin1String("http")) || scheme == QLatin1String("mailto")) return mimeTypeForName(d->defaultMimeType()); return mimeTypeForFile(url.path()); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 9bfc46f32e..c3aae2fd22 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -10092,6 +10092,9 @@ static inline int qt_find_latin1_string(const QChar *haystack, int size, QLatin1String needle, int from, Qt::CaseSensitivity cs) { + if (size < needle.size()) + return -1; + const char *latin1 = needle.latin1(); int len = needle.size(); QVarLengthArray<ushort> s(len); |