QHostInfo: address a Qt 6 todo

Merged the two functions, required adding a friend declaration

Change-Id: I86265da19e4b5f53d9e2dc54de3e252f0364225b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Mårten Nordheim 2020-08-21 13:54:29 +02:00
parent 467d215b32
commit 4573d29f64
2 changed files with 16 additions and 18 deletions

View File

@ -286,7 +286,7 @@ static int nextId()
*/
int QHostInfo::lookupHost(const QString &name, QObject *receiver, const char *member)
{
return QHostInfoPrivate::lookupHostImpl(name, receiver, nullptr, member);
return QHostInfo::lookupHostImpl(name, receiver, nullptr, member);
}
/*!
@ -773,14 +773,8 @@ QString QHostInfo::localHostName()
\sa hostName()
*/
// ### Qt 6 merge with function below
int QHostInfo::lookupHostImpl(const QString &name,
const QObject *receiver,
QtPrivate::QSlotObjectBase *slotObj)
{
return QHostInfoPrivate::lookupHostImpl(name, receiver, slotObj, nullptr);
}
/*
/*!
\internal
Called by the various lookupHost overloads to perform the lookup.
Signals either the functor encapuslated in the \a slotObj in the context
@ -788,13 +782,13 @@ int QHostInfo::lookupHostImpl(const QString &name,
\a receiver might be the nullptr, but only if a \a slotObj is provided.
*/
int QHostInfoPrivate::lookupHostImpl(const QString &name,
const QObject *receiver,
QtPrivate::QSlotObjectBase *slotObj,
const char *member)
int QHostInfo::lookupHostImpl(const QString &name,
const QObject *receiver,
QtPrivate::QSlotObjectBase *slotObj,
const char *member)
{
#if defined QHOSTINFO_DEBUG
qDebug("QHostInfoPrivate::lookupHostImpl(\"%s\", %p, %p, %s)",
qDebug("QHostInfo::lookupHostImpl(\"%s\", %p, %p, %s)",
name.toLatin1().constData(), receiver, slotObj, member ? member + 1 : 0);
#endif
Q_ASSERT(!member != !slotObj); // one of these must be set, but not both
@ -1098,7 +1092,7 @@ QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char
}
// was not in cache, trigger lookup
*id = QHostInfoPrivate::lookupHostImpl(name, receiver, nullptr, member);
*id = QHostInfo::lookupHostImpl(name, receiver, nullptr, member);
// return empty response, valid==false
return QHostInfo();

View File

@ -117,7 +117,7 @@ public:
"with the return type of the signal.");
auto slotObj = new QtPrivate::QSlotObject<Func, typename SlotType::Arguments, void>(slot);
return lookupHostImpl(name, receiver, slotObj);
return lookupHostImpl(name, receiver, slotObj, nullptr);
}
// lookupHost to a callable (without context)
@ -143,7 +143,7 @@ public:
auto slotObj = new QtPrivate::QFunctorSlotObject<Func1, 1,
typename QtPrivate::List<QHostInfo>,
void>(std::move(slot));
return lookupHostImpl(name, context, slotObj);
return lookupHostImpl(name, context, slotObj, nullptr);
}
#endif // Q_QDOC
@ -153,7 +153,11 @@ private:
static int lookupHostImpl(const QString &name,
const QObject *receiver,
QtPrivate::QSlotObjectBase *slotObj);
QtPrivate::QSlotObjectBase *slotObj,
const char *member);
friend QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver,
const char *member, bool *valid, int *id);
};
Q_DECLARE_SHARED(QHostInfo)