summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusabstractadaptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbus/qdbusabstractadaptor.cpp')
-rw-r--r--src/dbus/qdbusabstractadaptor.cpp81
1 files changed, 21 insertions, 60 deletions
diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp
index 8d99577929..afe769fcd0 100644
--- a/src/dbus/qdbusabstractadaptor.cpp
+++ b/src/dbus/qdbusabstractadaptor.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtDBus module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qdbusabstractadaptor.h"
#include "qdbusabstractadaptor_p.h"
@@ -58,14 +22,10 @@
QT_BEGIN_NAMESPACE
-static int cachedRelaySlotMethodIndex = -1;
-
int QDBusAdaptorConnector::relaySlotMethodIndex()
{
- if (cachedRelaySlotMethodIndex == -1) {
- cachedRelaySlotMethodIndex = staticMetaObject.indexOfMethod("relaySlot()");
- Q_ASSERT(cachedRelaySlotMethodIndex != -1);
- }
+ static const int cachedRelaySlotMethodIndex = staticMetaObject.indexOfMethod("relaySlot()");
+ Q_ASSERT(cachedRelaySlotMethodIndex != 0); // 0 should be deleteLater() or destroyed()
return cachedRelaySlotMethodIndex;
}
@@ -73,11 +33,9 @@ QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *obj)
{
if (!obj)
return nullptr;
- const QObjectList &children = obj->children();
- QObjectList::ConstIterator it = children.constBegin();
- QObjectList::ConstIterator end = children.constEnd();
- for ( ; it != end; ++it) {
- QDBusAdaptorConnector *connector = qobject_cast<QDBusAdaptorConnector *>(*it);
+
+ for (QObject *child : std::as_const(obj->children())) {
+ QDBusAdaptorConnector *connector = qobject_cast<QDBusAdaptorConnector *>(child);
if (connector) {
connector->polish();
return connector;
@@ -146,10 +104,13 @@ void QDBusAbstractAdaptorPrivate::saveIntrospectionXml(QDBusAbstractAdaptor *ada
QDBusAbstractAdaptor::QDBusAbstractAdaptor(QObject* obj)
: QObject(*new QDBusAbstractAdaptorPrivate, obj)
{
+
+ Q_ASSERT_X(obj, Q_FUNC_INFO, "Expected non-null parent");
+
QDBusAdaptorConnector *connector = qDBusCreateAdaptorConnector(obj);
connector->waitingForPolish = true;
- QMetaObject::invokeMethod(connector, "polish", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(connector, &QDBusAdaptorConnector::polish, Qt::QueuedConnection);
}
/*!
@@ -263,11 +224,8 @@ void QDBusAdaptorConnector::polish()
return; // avoid working multiple times if multiple adaptors were added
waitingForPolish = false;
- const QObjectList &objs = parent()->children();
- QObjectList::ConstIterator it = objs.constBegin();
- QObjectList::ConstIterator end = objs.constEnd();
- for ( ; it != end; ++it) {
- QDBusAbstractAdaptor *adaptor = qobject_cast<QDBusAbstractAdaptor *>(*it);
+ for (QObject *child : std::as_const(parent()->children())) {
+ QDBusAbstractAdaptor *adaptor = qobject_cast<QDBusAbstractAdaptor *>(child);
if (adaptor)
addAdaptor(adaptor);
}
@@ -296,8 +254,8 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
// QObject signal (destroyed(QObject *)) -- ignore
return;
- const QMetaObject *senderMetaObject = senderObj->metaObject();
- QMetaMethod mm = senderMetaObject->method(lastSignalIdx);
+ QMetaMethod mm = senderObj->metaObject()->method(lastSignalIdx);
+ const QMetaObject *senderMetaObject = mm.enclosingMetaObject();
QObject *realObject = senderObj;
if (qobject_cast<QDBusAbstractAdaptor *>(senderObj))
@@ -315,7 +273,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
qPrintable(errorMsg));
return;
}
- if (inputCount + 1 != types.count() ||
+ if (inputCount + 1 != types.size() ||
types.at(inputCount) == QDBusMetaTypeId::message()) {
// invalid signal signature
qWarning("QDBusAbstractAdaptor: Cannot relay signal %s::%s",
@@ -324,7 +282,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
}
QVariantList args;
- const int numTypes = types.count();
+ const int numTypes = types.size();
args.reserve(numTypes - 1);
for (int i = 1; i < numTypes; ++i)
args << QVariant(QMetaType(types.at(i)), argv[i]);
@@ -335,4 +293,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
QT_END_NAMESPACE
+#include "moc_qdbusabstractadaptor_p.cpp"
+#include "moc_qdbusabstractadaptor.cpp"
+
#endif // QT_NO_DBUS