diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-05-12 14:26:27 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-05-23 21:23:44 -0700 |
commit | 9a4eb45df1796787aa149e6f128eaafa225defab (patch) | |
tree | d4e1ffd70e2b412c4e4b0df6c2fb8d5c62423ab9 | |
parent | 282b078fca5ae5f485f6d80ff4afe4d58e178c8d (diff) |
QDnsLookup: simplify the processing of the runnable and reply
Change-Id: I3e3bfef633af4130a03afffd175e827dce2af966
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | src/network/kernel/qdnslookup.cpp | 31 | ||||
-rw-r--r-- | src/network/kernel/qdnslookup.h | 1 | ||||
-rw-r--r-- | src/network/kernel/qdnslookup_p.h | 2 |
3 files changed, 15 insertions, 19 deletions
diff --git a/src/network/kernel/qdnslookup.cpp b/src/network/kernel/qdnslookup.cpp index 645ed31b02..4f991fd7e3 100644 --- a/src/network/kernel/qdnslookup.cpp +++ b/src/network/kernel/qdnslookup.cpp @@ -1,4 +1,5 @@ // Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> +// Copyright (C) 2023 Intel Corporation. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qdnslookup.h" @@ -530,9 +531,21 @@ void QDnsLookup::lookup() Q_D(QDnsLookup); d->isFinished = false; d->reply = QDnsLookupReply(); + auto l = [this](const QDnsLookupReply &reply) { + Q_D(QDnsLookup); + if (d->runnable == sender()) { +#ifdef QDNSLOOKUP_DEBUG + qDebug("DNS reply for %s: %i (%s)", qPrintable(d->name), reply.error, qPrintable(reply.errorString)); +#endif + d->reply = reply; + d->runnable = nullptr; + d->isFinished = true; + emit finished(); + } + }; + d->runnable = new QDnsLookupRunnable(d); - connect(d->runnable, &QDnsLookupRunnable::finished, - this, [this](const QDnsLookupReply &reply) { d_func()->_q_lookupFinished(reply); }, + connect(d->runnable, &QDnsLookupRunnable::finished, this, l, Qt::BlockingQueuedConnection); theDnsLookupThreadPool->start(d->runnable); } @@ -1011,20 +1024,6 @@ QDnsTextRecord &QDnsTextRecord::operator=(const QDnsTextRecord &other) very fast and never fails. */ -void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply) -{ - Q_Q(QDnsLookup); - if (runnable == q->sender()) { -#ifdef QDNSLOOKUP_DEBUG - qDebug("DNS reply for %s: %i (%s)", qPrintable(name), _reply.error, qPrintable(_reply.errorString)); -#endif - reply = _reply; - runnable = nullptr; - isFinished = true; - emit q->finished(); - } -} - inline QDnsLookupRunnable::QDnsLookupRunnable(const QDnsLookupPrivate *d) : requestName(QUrl::toAce(d->name)), nameserver(d->nameserver), diff --git a/src/network/kernel/qdnslookup.h b/src/network/kernel/qdnslookup.h index ca7cb617cc..1bd1b8e5ae 100644 --- a/src/network/kernel/qdnslookup.h +++ b/src/network/kernel/qdnslookup.h @@ -226,7 +226,6 @@ Q_SIGNALS: private: Q_DECLARE_PRIVATE(QDnsLookup) - Q_PRIVATE_SLOT(d_func(), void _q_lookupFinished(const QDnsLookupReply &reply)) }; QT_END_NAMESPACE diff --git a/src/network/kernel/qdnslookup_p.h b/src/network/kernel/qdnslookup_p.h index a1ffb5f20b..84deaa0fd6 100644 --- a/src/network/kernel/qdnslookup_p.h +++ b/src/network/kernel/qdnslookup_p.h @@ -123,8 +123,6 @@ public: : type(QDnsLookup::A) , port(DnsPort) { } - void _q_lookupFinished(const QDnsLookupReply &reply); - void nameChanged() { |