QHostInfo: fix lookupHost() signature immediately

... 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 <marten.nordheim@qt.io>
(cherry picked from commit 4b3d6be5f5a175a4c66b527eb2df49d62dc30056)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-01-23 14:19:59 +01:00 committed by Qt Cherry-pick Bot
parent dcaab5eb8d
commit a3b4b060cf
3 changed files with 18 additions and 2 deletions

View File

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

View File

@ -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");

View File

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