diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-07-03 22:32:50 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-07-07 05:22:33 +0000 |
commit | 8b5cdc20be5df287f61fce25998bb5dc4bcf73fb (patch) | |
tree | 3657d7c45daa493524ee994767e2e963101e574c | |
parent | 6aa89ddf5e30bf3a0b3814140872b71cfbae9796 (diff) |
QProcessEnvironment: fix op==
Not all empty states were considered equal.
[ChangeLog][QtCore][QProcessEnvironment] Fixed a bug in
operator== involving different empty states.
Change-Id: I13c3200897847475bde2f963db0d2c587336b8a7
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/io/qprocess.cpp | 13 | ||||
-rw-r--r-- | tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp | 10 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 218e8b959c..8a1fda6ccb 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -264,11 +264,16 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const { if (d == other.d) return true; - if (d && other.d) { - QProcessEnvironmentPrivate::OrderedMutexLocker locker(d, other.d); - return d->hash == other.d->hash; + if (d) { + if (other.d) { + QProcessEnvironmentPrivate::OrderedMutexLocker locker(d, other.d); + return d->hash == other.d->hash; + } else { + return isEmpty(); + } + } else { + return other.isEmpty(); } - return false; } /*! diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp index fb64a48362..2099101a91 100644 --- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp @@ -66,11 +66,19 @@ void tst_QProcessEnvironment::operator_eq() QVERIFY(e1 == e2); e1.clear(); - QVERIFY(e1 != e2); + QVERIFY(e1 == e2); e2.clear(); + QVERIFY(e1 == e2); + e1.insert("FOO", "bar"); + QVERIFY(e1 != e2); + + e2.insert("FOO", "bar"); QVERIFY(e1 == e2); + + e2.insert("FOO", "baz"); + QVERIFY(e1 != e2); } void tst_QProcessEnvironment::clearAndIsEmpty() |