Fix QHostAddress::operator==(QHostAddress::SpecialAddress)

QHostAddress(QHostAddress::Any) was not equal to QHostAddress::Any
because only one of the operator== overloads was handling this.

Task-number: QTBUG-22898
Change-Id: Ifd36947a50e8c36362b4e850fd8d5105ee0925ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Shane Kearns 2011-11-30 15:42:05 +00:00 committed by Qt by Nokia
parent 6468dd4179
commit 49140efe2d
2 changed files with 6 additions and 0 deletions

View File

@ -899,6 +899,8 @@ bool QHostAddress::operator ==(SpecialAddress other) const
return otherAddress.d->protocol == QAbstractSocket::IPv6Protocol
&& memcmp(&d->a6, &otherAddress.d->a6, sizeof(Q_IPV6ADDR)) == 0;
}
if (d->protocol == QAbstractSocket::AnyIPProtocol)
return other == QHostAddress::Any;
return int(other) == int(Null);
}

View File

@ -285,6 +285,10 @@ void tst_QHostAddress::specialAddresses()
QFETCH(bool, result);
QVERIFY((QHostAddress(text) == (QHostAddress::SpecialAddress)address) == result);
//check special address equal to itself (QTBUG-22898), note two overloads of operator==
QVERIFY(QHostAddress((QHostAddress::SpecialAddress)address) == QHostAddress((QHostAddress::SpecialAddress)address));
QVERIFY(QHostAddress((QHostAddress::SpecialAddress)address) == (QHostAddress::SpecialAddress)address);
QHostAddress setter;
setter.setAddress(text);
if (result) {