diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index 9b3015ecf0..57e66142ca 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -401,7 +401,11 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const return d->valueDelimiter == other.d->valueDelimiter && d->pairDelimiter == other.d->pairDelimiter && d->itemList == other.d->itemList; - return false; + + const QUrlQueryPrivate *x = d ? d.data() : other.d.data(); + return x->valueDelimiter == defaultQueryValueDelimiter() && + x->pairDelimiter == defaultQueryPairDelimiter() && + x->itemList.isEmpty(); } /*! diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp index 1774938096..41482f4256 100644 --- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp +++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp @@ -210,12 +210,14 @@ void tst_QUrlQuery::constructing() void tst_QUrlQuery::addRemove() { QUrlQuery query; + QCOMPARE(query, query); { // one item query.addQueryItem("a", "b"); QVERIFY(!query.isEmpty()); QVERIFY(query.hasQueryItem("a")); + QCOMPARE_NE(query, QUrlQuery()); QCOMPARE(query.queryItemValue("a"), QString("b")); QCOMPARE(query.allQueryItemValues("a"), QStringList() << "b"); @@ -226,6 +228,7 @@ void tst_QUrlQuery::addRemove() } QUrlQuery original = query; + QCOMPARE(query, original); { // two items @@ -298,6 +301,9 @@ void tst_QUrlQuery::addRemove() query.removeQueryItem("a"); query.removeQueryItem("e"); QVERIFY(query.isEmpty()); + QVERIFY(query.isDetached()); + QCOMPARE_NE(query, original); + QCOMPARE(query, QUrlQuery()); } }