summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostaddress.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-11-29 15:30:52 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2016-12-07 13:21:20 +0000
commit4077fcc6153493284b5e2b0812ff215b49e8c8b7 (patch)
tree83f2643e479437b69388255a400c981dea74f8cc /src/network/kernel/qhostaddress.h
parent630f8e7ad6e94c703f85fa11a9926ba83c478e72 (diff)
QHostAddress: fix assignment operators
QHostAddress allowed assignment from a QString, but the respective constructor is explicit, and rightfully so. So it does not make sense that the assignment operator is provided, because of the asymmetry caused between QHostAddress addr = funcReturningQString(); // ERROR addr = funcReturningQString(); // OK (until now) By the same token, since SpecialAddress is implicitly convertible to QHostAddress, provide the missing assignment operator from that enum. Add tests, rewriting the _data() function to use the enum instead of an int to pass SpecialAddress values, and to test !=, too. Added setAddress(SpecialAddress), since a) it was missing and b) to share code between the ctor and the assignment operator. Change-Id: Ief64c493be13ada8c6968801d9ed083b267fa902 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/kernel/qhostaddress.h')
-rw-r--r--src/network/kernel/qhostaddress.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index 58af14ee33..10fe33f6fa 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -108,7 +108,11 @@ public:
#endif
QHostAddress &operator=(const QHostAddress &other);
+#if QT_DEPRECATED_SINCE(5, 8)
+ QT_DEPRECATED_X("use = QHostAddress(string) instead")
QHostAddress &operator=(const QString &address);
+#endif
+ QHostAddress &operator=(SpecialAddress address);
void swap(QHostAddress &other) Q_DECL_NOTHROW { d.swap(other.d); }
@@ -118,6 +122,7 @@ public:
void setAddress(const Q_IPV6ADDR &ip6Addr);
void setAddress(const sockaddr *address);
bool setAddress(const QString &address);
+ void setAddress(SpecialAddress address);
QAbstractSocket::NetworkLayerProtocol protocol() const;
quint32 toIPv4Address() const; // ### Qt6: merge with next overload