diff options
author | Liang Qi <liang.qi@qt.io> | 2017-06-19 13:25:11 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-06-19 16:12:34 +0200 |
commit | ce09ef431373f45d14ce0a6e7de24aee3666093d (patch) | |
tree | 7c998b21f02db55e233e7eeb1599663f1c6b51ca /src/corelib/io/qprocess_p.h | |
parent | 7ad55ca65f42351e231f31f7a9253ae6eaf1ebb3 (diff) | |
parent | 97eec16e4ff6367c233f8ea6c4a343c286c3a514 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/corelib/io/qprocess_unix.cpp
src/corelib/io/qprocess_win.cpp
src/plugins/platforms/android/qandroidplatformintegration.h
src/plugins/platforms/windows/qwindowscontext.cpp
src/plugins/platforms/windows/windows.pri
src/tools/uic/cpp/cppwriteinitialization.cpp
src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
Diffstat (limited to 'src/corelib/io/qprocess_p.h')
-rw-r--r-- | src/corelib/io/qprocess_p.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index bea54f86da..deb29dca0a 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -55,6 +55,7 @@ #include "QtCore/qprocess.h" #include "QtCore/qstringlist.h" #include "QtCore/qhash.h" +#include "QtCore/qmap.h" #include "QtCore/qshareddata.h" #include "private/qiodevice_p.h" @@ -90,22 +91,19 @@ public: QProcEnvKey(const QProcEnvKey &other) : QString(other) {} bool operator==(const QProcEnvKey &other) const { return !compare(other, Qt::CaseInsensitive); } }; -inline uint qHash(const QProcEnvKey &key) { return qHash(key.toCaseFolded()); } -typedef QString QProcEnvValue; -#else -class QProcEnvKey +inline bool operator<(const QProcEnvKey &a, const QProcEnvKey &b) { -public: - QProcEnvKey() : hash(0) {} - explicit QProcEnvKey(const QByteArray &other) : key(other), hash(qHash(key)) {} - QProcEnvKey(const QProcEnvKey &other) { *this = other; } - bool operator==(const QProcEnvKey &other) const { return key == other.key; } + // On windows use case-insensitive ordering because that is how Windows needs the environment + // block sorted (https://msdn.microsoft.com/en-us/library/windows/desktop/ms682009(v=vs.85).aspx) + return a.compare(b, Qt::CaseInsensitive) < 0; +} - QByteArray key; - uint hash; -}; -inline uint qHash(const QProcEnvKey &key) Q_DECL_NOTHROW { return key.hash; } +Q_DECLARE_TYPEINFO(QProcEnvKey, Q_MOVABLE_TYPE); + +typedef QString QProcEnvValue; +#else +using QProcEnvKey = QByteArray; class QProcEnvValue { @@ -138,7 +136,6 @@ public: }; Q_DECLARE_TYPEINFO(QProcEnvValue, Q_MOVABLE_TYPE); #endif -Q_DECLARE_TYPEINFO(QProcEnvKey, Q_MOVABLE_TYPE); class QProcessEnvironmentPrivate: public QSharedData { @@ -161,13 +158,13 @@ public: inline Key prepareName(const QString &name) const { Key &ent = nameMap[name]; - if (ent.key.isEmpty()) - ent = Key(name.toLocal8Bit()); + if (ent.isEmpty()) + ent = name.toLocal8Bit(); return ent; } inline QString nameToString(const Key &name) const { - const QString sname = QString::fromLocal8Bit(name.key); + const QString sname = QString::fromLocal8Bit(name); nameMap[sname] = name; return sname; } @@ -197,17 +194,17 @@ public: // do not need a lock, as they detach objects (however, we need to // ensure that they really detach before using prepareName()). MutexLocker locker(&other); - hash = other.hash; + vars = other.vars; nameMap = other.nameMap; // We need to detach our members, so that our mutex can protect them. // As we are being detached, they likely would be detached a moment later anyway. - hash.detach(); + vars.detach(); nameMap.detach(); } #endif - typedef QHash<Key, Value> Hash; - Hash hash; + using Map = QMap<Key, Value>; + Map vars; #ifdef Q_OS_UNIX typedef QHash<QString, Key> NameHash; |