QtDBus: Use invokeMethod accepting member functions with arguments
This makes the code slightly more readable. Rename one overload of QDBusConnectionManager::doConnectToBus to avoid using qOverload. Change-Id: Id878e5baade539c3f748b5bf66a5aff726604b89 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
712149802b
commit
a6027d4c59
|
|
@ -164,12 +164,9 @@ QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(QDBusConnection::Bu
|
|||
{
|
||||
QDBusConnectionPrivate *result = nullptr;
|
||||
|
||||
QMetaObject::invokeMethod(
|
||||
this,
|
||||
[this, type, &name, suspendedDelivery] {
|
||||
return doConnectToBus(type, name, suspendedDelivery);
|
||||
},
|
||||
Qt::BlockingQueuedConnection, &result);
|
||||
QMetaObject::invokeMethod(this, &QDBusConnectionManager::doConnectToStandardBus,
|
||||
Qt::BlockingQueuedConnection, qReturnArg(result), type, name,
|
||||
suspendedDelivery);
|
||||
|
||||
if (suspendedDelivery && result && result->connection)
|
||||
result->enableDispatchDelayed(qApp); // qApp was checked in the caller
|
||||
|
|
@ -181,9 +178,8 @@ QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(const QString &addr
|
|||
{
|
||||
QDBusConnectionPrivate *result = nullptr;
|
||||
|
||||
QMetaObject::invokeMethod(
|
||||
this, [this, &address, &name] { return doConnectToBus(address, name); },
|
||||
Qt::BlockingQueuedConnection, &result);
|
||||
QMetaObject::invokeMethod(this, &QDBusConnectionManager::doConnectToBus,
|
||||
Qt::BlockingQueuedConnection, qReturnArg(result), address, name);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -192,16 +188,15 @@ QDBusConnectionPrivate *QDBusConnectionManager::connectToPeer(const QString &add
|
|||
{
|
||||
QDBusConnectionPrivate *result = nullptr;
|
||||
|
||||
QMetaObject::invokeMethod(
|
||||
this, [this, &address, &name] { return doConnectToPeer(address, name); },
|
||||
Qt::BlockingQueuedConnection, &result);
|
||||
QMetaObject::invokeMethod(this, &QDBusConnectionManager::doConnectToPeer,
|
||||
Qt::BlockingQueuedConnection, qReturnArg(result), address, name);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QDBusConnectionPrivate *QDBusConnectionManager::doConnectToBus(QDBusConnection::BusType type,
|
||||
const QString &name,
|
||||
bool suspendedDelivery)
|
||||
QDBusConnectionPrivate *
|
||||
QDBusConnectionManager::doConnectToStandardBus(QDBusConnection::BusType type, const QString &name,
|
||||
bool suspendedDelivery)
|
||||
{
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ protected:
|
|||
void run() override;
|
||||
|
||||
private:
|
||||
QDBusConnectionPrivate *doConnectToBus(QDBusConnection::BusType type, const QString &name,
|
||||
bool suspendedDelivery);
|
||||
QDBusConnectionPrivate *doConnectToStandardBus(QDBusConnection::BusType type,
|
||||
const QString &name, bool suspendedDelivery);
|
||||
QDBusConnectionPrivate *doConnectToBus(const QString &address, const QString &name);
|
||||
QDBusConnectionPrivate *doConnectToPeer(const QString &address, const QString &name);
|
||||
|
||||
|
|
|
|||
|
|
@ -2714,8 +2714,8 @@ void QDBusConnectionPrivate::enableDispatchDelayed(QObject *context)
|
|||
// This call cannot race with something disabling dispatch only
|
||||
// because dispatch is never re-disabled from Qt code on an
|
||||
// in-use connection once it has been enabled.
|
||||
QMetaObject::invokeMethod(
|
||||
this, [this] { setDispatchEnabled(true); }, Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::setDispatchEnabled,
|
||||
Qt::QueuedConnection, true);
|
||||
if (!ref.deref())
|
||||
deleteLater();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue