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>
This commit is contained in:
Marc Mutz 2015-07-03 22:32:50 +02:00
parent 6aa89ddf5e
commit 8b5cdc20be
2 changed files with 19 additions and 6 deletions

View File

@ -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;
}
/*!

View File

@ -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()