From a3b4b060cf05a4bd6547726e08a9ce1bbb26f1bd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 23 Jan 2024 14:19:59 +0100 Subject: [PATCH] QHostInfo: fix lookupHost() signature immediately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... and not just for Qt 7. Found in API-Review. Amends dd50d58af267bd3b79d1ca31b920d72b925d5a37. [ChangeLog][QtNetwork][QHostInfo] The lookupHost() static function now takes const QObject* receivers (was: (non-const) QObject*). Change-Id: I22b11e06cfba4e96975239cabed8b379cf3f4fa4 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 4b3d6be5f5a175a4c66b527eb2df49d62dc30056) Reviewed-by: Qt Cherry-pick Bot --- src/network/compat/removed_api.cpp | 10 ++++++++++ src/network/kernel/qhostinfo.cpp | 5 ++++- src/network/kernel/qhostinfo.h | 5 ++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/network/compat/removed_api.cpp b/src/network/compat/removed_api.cpp index 969ad9cd3be..956018cece0 100644 --- a/src/network/compat/removed_api.cpp +++ b/src/network/compat/removed_api.cpp @@ -9,6 +9,16 @@ QT_USE_NAMESPACE #if QT_NETWORK_REMOVED_SINCE(6, 7) +#include "qhostinfo.h" + +// static +int QHostInfo::lookupHost(const QString &name, QObject *receiver, const char *member) +{ + const auto *r = receiver; + return lookupHost(name, r, member); +} + + #include "qnetworkreply.h" QByteArray QNetworkReply::rawHeader(const QByteArray &headerName) const diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 99ed32b8034..62bb210ca17 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -221,9 +221,12 @@ static int nextId() \note There is no guarantee on the order the signals will be emitted if you start multiple requests with lookupHost(). + \note In Qt versions prior to 6.7, this function took \a receiver as + (non-const) \c{QObject*}. + \sa abortHostLookup(), addresses(), error(), fromName() */ -int QHostInfo::lookupHost(const QString &name, QT7_ONLY(const) QObject *receiver, const char *member) +int QHostInfo::lookupHost(const QString &name, const QObject *receiver, const char *member) { if (!receiver || !member) { qWarning("QHostInfo::lookupHost: both the receiver and the member to invoke must be non-null"); diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h index 12a2db7e8b7..e338a0b6d56 100644 --- a/src/network/kernel/qhostinfo.h +++ b/src/network/kernel/qhostinfo.h @@ -48,7 +48,10 @@ public: void setLookupId(int id); int lookupId() const; - static int lookupHost(const QString &name, QT7_ONLY(const) QObject *receiver, const char *member); +#if QT_NETWORK_REMOVED_SINCE(6, 7) + static int lookupHost(const QString &name, QObject *receiver, const char *member); +#endif + static int lookupHost(const QString &name, const QObject *receiver, const char *member); static void abortHostLookup(int lookupId); static QHostInfo fromName(const QString &name);