QHostInfo: fix lookupHost() signature immediately

... and not just for Qt 7.

Found in API-Review.

Amends dd50d58af2.

[ChangeLog][QtNetwork][QHostInfo] The lookupHost() static function now
takes const QObject* receivers (was: (non-const) QObject*).

Pick-to: 6.7
Change-Id: I22b11e06cfba4e96975239cabed8b379cf3f4fa4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
bb10
Marc Mutz 2024-01-23 14:19:59 +01:00
parent 081e50d768
commit 4b3d6be5f5
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);