mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-04 08:15:30 +08:00
qt 6.6.0 clean
This commit is contained in:
@ -52,8 +52,9 @@ qt_internal_add_module(DBus
|
||||
GENERATE_CPP_EXPORTS
|
||||
)
|
||||
|
||||
# This file is included by qdbusargument.cpp
|
||||
set_source_files_properties(qdbusmarshaller.cpp
|
||||
PROPERTIES HEADER_FILE_ONLY ON) # special case: This file is included by qdbusargument.cpp
|
||||
PROPERTIES HEADER_FILE_ONLY ON)
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
@ -52,7 +52,7 @@ QDBusPendingCall pcall = interface->asyncCall("Process"_L1, value);
|
||||
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall);
|
||||
|
||||
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
||||
this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this,
|
||||
&Abstract_DBus_Interface::callFinishedSlot);
|
||||
//! [1]
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ QString MyObject::methodWithDelayedReply()
|
||||
conn = connection();
|
||||
msg = message();
|
||||
setDelayedReply(true);
|
||||
QMetaObject::invokeMethod(this, "process", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, &MyObject::process, Qt::QueuedConnection);
|
||||
return QString();
|
||||
}
|
||||
//! [0]
|
||||
|
@ -33,8 +33,8 @@ void DBus_PendingCall_Interface::callInterfaceMain()
|
||||
QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
|
||||
|
||||
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
||||
this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this,
|
||||
&DBus_PendingCall_Interface::callFinishedSlot);
|
||||
//! [0]
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
\page qtdbus-overview.html
|
||||
\title Qt D-Bus Overview
|
||||
\brief Provides insight into the Qt Qt D-Bus module.
|
||||
\ingroup explanations-networkingandconnectivity
|
||||
|
||||
D-Bus is an Inter-Process Communication (IPC) and Remote Procedure
|
||||
Calling (RPC) mechanism originally developed for Linux to replace
|
||||
|
@ -3,6 +3,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qlatin1stringview.h>
|
||||
#if QT_CONFIG(library)
|
||||
#include <QtCore/qlibrary.h>
|
||||
#include <QtCore/private/qlocking_p.h>
|
||||
|
@ -37,11 +37,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;
|
||||
@ -113,7 +111,7 @@ QDBusAbstractAdaptor::QDBusAbstractAdaptor(QObject* obj)
|
||||
QDBusAdaptorConnector *connector = qDBusCreateAdaptorConnector(obj);
|
||||
|
||||
connector->waitingForPolish = true;
|
||||
QMetaObject::invokeMethod(connector, "polish", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(connector, &QDBusAdaptorConnector::polish, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -227,11 +225,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);
|
||||
}
|
||||
|
@ -222,10 +222,8 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &l
|
||||
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantList &list)
|
||||
{
|
||||
arg.beginArray(QMetaType::fromType<QDBusVariant>());
|
||||
QVariantList::ConstIterator it = list.constBegin();
|
||||
QVariantList::ConstIterator end = list.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
arg << QDBusVariant(*it);
|
||||
for (const QVariant &value : list)
|
||||
arg << QDBusVariant(value);
|
||||
arg.endArray();
|
||||
return arg;
|
||||
}
|
||||
@ -284,11 +282,9 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<Key,
|
||||
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
|
||||
{
|
||||
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
|
||||
QVariantMap::ConstIterator it = map.constBegin();
|
||||
QVariantMap::ConstIterator end = map.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const auto &[key, value] : map.asKeyValueRange()) {
|
||||
arg.beginMapEntry();
|
||||
arg << it.key() << QDBusVariant(it.value());
|
||||
arg << key << QDBusVariant(value);
|
||||
arg.endMapEntry();
|
||||
}
|
||||
arg.endMap();
|
||||
@ -298,11 +294,9 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
|
||||
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
|
||||
{
|
||||
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
|
||||
QVariantHash::ConstIterator it = map.constBegin();
|
||||
QVariantHash::ConstIterator end = map.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const auto &[key, value] : map.asKeyValueRange()) {
|
||||
arg.beginMapEntry();
|
||||
arg << it.key() << QDBusVariant(it.value());
|
||||
arg << key << QDBusVariant(value);
|
||||
arg.endMapEntry();
|
||||
}
|
||||
arg.endMap();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qdbuspendingcall_p.h"
|
||||
|
||||
#include "qdbusthreaddebug_p.h"
|
||||
#include "qdbusmetatype_p.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -82,6 +83,13 @@ void QDBusConnectionManager::removeConnection(const QString &name)
|
||||
|
||||
QDBusConnectionManager::QDBusConnectionManager()
|
||||
{
|
||||
// Ensure that the custom metatype registry is created before the instance
|
||||
// of this class. This will ensure that the registry is not destroyed before
|
||||
// the connection manager at application exit (see also QTBUG-58732). This
|
||||
// works with compilers that use mechanism similar to atexit() to call
|
||||
// destructurs for global statics.
|
||||
QDBusMetaTypeId::init();
|
||||
|
||||
connect(this, &QDBusConnectionManager::connectionRequested,
|
||||
this, &QDBusConnectionManager::executeConnectionRequest, Qt::BlockingQueuedConnection);
|
||||
connect(this, &QDBusConnectionManager::serverRequested,
|
||||
@ -124,9 +132,7 @@ void QDBusConnectionManager::run()
|
||||
|
||||
// cleanup:
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
for (QHash<QString, QDBusConnectionPrivate *>::const_iterator it = connectionHash.constBegin();
|
||||
it != connectionHash.constEnd(); ++it) {
|
||||
QDBusConnectionPrivate *d = it.value();
|
||||
for (QDBusConnectionPrivate *d : std::as_const(connectionHash)) {
|
||||
if (!d->ref.deref()) {
|
||||
delete d;
|
||||
} else {
|
||||
@ -150,12 +156,9 @@ QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(QDBusConnection::Bu
|
||||
data.suspendedDelivery = suspendedDelivery;
|
||||
|
||||
emit connectionRequested(&data);
|
||||
if (suspendedDelivery && data.result->connection) {
|
||||
data.result->ref.ref();
|
||||
QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(data.result);
|
||||
QTimer::singleShot(0, o, SLOT(execute()));
|
||||
o->moveToThread(qApp->thread()); // qApp was checked in the caller
|
||||
}
|
||||
if (suspendedDelivery && data.result->connection)
|
||||
data.result->enableDispatchDelayed(qApp); // qApp was checked in the caller
|
||||
|
||||
return data.result;
|
||||
}
|
||||
|
||||
|
@ -212,6 +212,8 @@ public:
|
||||
|
||||
void postEventToThread(int action, QObject *target, QEvent *event);
|
||||
|
||||
void enableDispatchDelayed(QObject *context);
|
||||
|
||||
private:
|
||||
void checkThread();
|
||||
bool handleError(const QDBusErrorInternal &error);
|
||||
@ -357,26 +359,6 @@ extern QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNod
|
||||
extern QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &node,
|
||||
const QDBusMessage &msg);
|
||||
|
||||
// can be replaced with a lambda in Qt 5.7
|
||||
class QDBusConnectionDispatchEnabler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QDBusConnectionPrivate *con;
|
||||
public:
|
||||
QDBusConnectionDispatchEnabler(QDBusConnectionPrivate *con) : con(con) {}
|
||||
|
||||
public slots:
|
||||
void execute()
|
||||
{
|
||||
// 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(con, "setDispatchEnabled", Qt::QueuedConnection, Q_ARG(bool, true));
|
||||
if (!con->ref.deref())
|
||||
con->deleteLater();
|
||||
deleteLater();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -124,8 +124,7 @@ static dbus_bool_t qDBusAddTimeout(DBusTimeout *timeout, void *data)
|
||||
|
||||
Q_ASSERT(d->timeouts.key(timeout, 0) == 0);
|
||||
|
||||
int timerId = d->startTimer(q_dbus_timeout_get_interval(timeout));
|
||||
Q_ASSERT_X(timerId, "QDBusConnection", "Failed to start a timer");
|
||||
int timerId = d->startTimer(std::chrono::milliseconds{q_dbus_timeout_get_interval(timeout)});
|
||||
if (!timerId)
|
||||
return false;
|
||||
|
||||
@ -293,12 +292,8 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
|
||||
// QDBusServer's thread in order to enable it after the
|
||||
// QDBusServer::newConnection() signal has been received by the
|
||||
// application's code
|
||||
newConnection->ref.ref();
|
||||
QReadLocker serverLock(&serverConnection->lock);
|
||||
QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(newConnection);
|
||||
QTimer::singleShot(0, o, SLOT(execute()));
|
||||
if (serverConnection->serverObject)
|
||||
o->moveToThread(serverConnection->serverObject->thread());
|
||||
newConnection->enableDispatchDelayed(serverConnection->serverObject);
|
||||
}
|
||||
|
||||
void QDBusConnectionPrivate::_q_newConnection(QDBusConnectionPrivate *newConnection)
|
||||
@ -409,17 +404,14 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
|
||||
pos = (pos == -1 ? length : pos);
|
||||
auto pathComponent = QStringView{fullpath}.mid(start, pos - start);
|
||||
|
||||
const QObjectList children = obj->children();
|
||||
|
||||
// find a child with the proper name
|
||||
QObject *next = nullptr;
|
||||
QObjectList::ConstIterator it = children.constBegin();
|
||||
QObjectList::ConstIterator end = children.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
if ((*it)->objectName() == pathComponent) {
|
||||
next = *it;
|
||||
for (QObject *child : std::as_const(obj->children())) {
|
||||
if (child->objectName() == pathComponent) {
|
||||
next = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!next)
|
||||
break;
|
||||
@ -561,7 +553,7 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
|
||||
|
||||
static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNode &haystack)
|
||||
{
|
||||
for (auto &node : haystack.children)
|
||||
for (QDBusConnectionPrivate::ObjectTreeNode &node : haystack.children)
|
||||
huntAndDestroy(needle, node);
|
||||
|
||||
auto isInactive = [](const QDBusConnectionPrivate::ObjectTreeNode &node) { return !node.isActive(); };
|
||||
@ -605,11 +597,11 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
|
||||
QObject *needle, const QDBusConnectionPrivate::ObjectTreeNode &haystack,
|
||||
bool isScriptable, bool isAdaptor, const QString &path = QString())
|
||||
{
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = haystack.children.constBegin();
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end = haystack.children.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
if (it->isActive())
|
||||
huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + u'/' + it->name);
|
||||
for (const QDBusConnectionPrivate::ObjectTreeNode &node : std::as_const(haystack.children)) {
|
||||
if (node.isActive()) {
|
||||
huntAndEmit(connection, msg, needle, node, isScriptable, isAdaptor,
|
||||
path + u'/' + node.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (needle == haystack.obj) {
|
||||
@ -996,8 +988,6 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
|
||||
return;
|
||||
}
|
||||
|
||||
extern bool qDBusInitThreads();
|
||||
|
||||
QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
|
||||
: QObject(p),
|
||||
ref(1),
|
||||
@ -1076,12 +1066,8 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate()
|
||||
void QDBusConnectionPrivate::collectAllObjects(QDBusConnectionPrivate::ObjectTreeNode &haystack,
|
||||
QSet<QObject *> &set)
|
||||
{
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = haystack.children.begin();
|
||||
|
||||
while (it != haystack.children.end()) {
|
||||
collectAllObjects(*it, set);
|
||||
it++;
|
||||
}
|
||||
for (ObjectTreeNode &child : haystack.children)
|
||||
collectAllObjects(child, set);
|
||||
|
||||
if (haystack.obj)
|
||||
set.insert(haystack.obj);
|
||||
@ -1109,11 +1095,9 @@ void QDBusConnectionPrivate::closeConnection()
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
|
||||
auto call = *it;
|
||||
if (!call->ref.deref()) {
|
||||
for (QDBusPendingCallPrivate *call : pendingCalls) {
|
||||
if (!call->ref.deref())
|
||||
delete call;
|
||||
}
|
||||
}
|
||||
pendingCalls.clear();
|
||||
|
||||
@ -1124,18 +1108,12 @@ void QDBusConnectionPrivate::closeConnection()
|
||||
// dangling pointer.
|
||||
QSet<QObject *> allObjects;
|
||||
collectAllObjects(rootNode, allObjects);
|
||||
SignalHookHash::const_iterator sit = signalHooks.constBegin();
|
||||
while (sit != signalHooks.constEnd()) {
|
||||
allObjects.insert(sit.value().obj);
|
||||
++sit;
|
||||
}
|
||||
for (const SignalHook &signalHook : std::as_const(signalHooks))
|
||||
allObjects.insert(signalHook.obj);
|
||||
|
||||
// now disconnect ourselves
|
||||
QSet<QObject *>::const_iterator oit = allObjects.constBegin();
|
||||
while (oit != allObjects.constEnd()) {
|
||||
(*oit)->disconnect(this);
|
||||
++oit;
|
||||
}
|
||||
for (QObject *obj : std::as_const(allObjects))
|
||||
obj->disconnect(this);
|
||||
}
|
||||
|
||||
void QDBusConnectionPrivate::handleDBusDisconnection()
|
||||
@ -1177,11 +1155,9 @@ void QDBusConnectionPrivate::doDispatch()
|
||||
if (mode == ClientMode || mode == PeerMode) {
|
||||
if (dispatchEnabled && !pendingMessages.isEmpty()) {
|
||||
// dispatch previously queued messages
|
||||
PendingMessageList::Iterator it = pendingMessages.begin();
|
||||
PendingMessageList::Iterator end = pendingMessages.end();
|
||||
for ( ; it != end; ++it) {
|
||||
qDBusDebug() << this << "dequeueing message" << *it;
|
||||
handleMessage(std::move(*it));
|
||||
for (QDBusMessage &message : pendingMessages) {
|
||||
qDBusDebug() << this << "dequeueing message" << message;
|
||||
handleMessage(std::move(message));
|
||||
}
|
||||
pendingMessages.clear();
|
||||
}
|
||||
@ -1461,14 +1437,11 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
|
||||
if (msg.interface().isEmpty()) {
|
||||
// place the call in all interfaces
|
||||
// let the first one that handles it to work
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator it =
|
||||
connector->adaptors.constBegin();
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator end =
|
||||
connector->adaptors.constEnd();
|
||||
|
||||
for ( ; it != end; ++it)
|
||||
if (activateCall(it->adaptor, newflags, msg))
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
if (activateCall(adaptorData.adaptor, newflags, msg))
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// check if we have an interface matching the name that was asked:
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
|
||||
@ -1757,10 +1730,10 @@ void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal
|
||||
|
||||
watchForDBusDisconnection();
|
||||
|
||||
QMetaObject::invokeMethod(this, "doDispatch", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnection *connection)
|
||||
static QDBusConnection::ConnectionCapabilities connectionCapabilities(DBusConnection *connection)
|
||||
{
|
||||
QDBusConnection::ConnectionCapabilities result;
|
||||
typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int);
|
||||
@ -1786,7 +1759,7 @@ static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnecti
|
||||
|
||||
void QDBusConnectionPrivate::handleAuthentication()
|
||||
{
|
||||
capabilities.storeRelaxed(connectionCapabilies(connection));
|
||||
capabilities.storeRelaxed(::connectionCapabilities(connection));
|
||||
isAuthenticated = true;
|
||||
}
|
||||
|
||||
@ -1845,7 +1818,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
|
||||
qDBusDebug() << this << ": connected successfully";
|
||||
|
||||
// schedule a dispatch:
|
||||
QMetaObject::invokeMethod(this, "doDispatch", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
extern "C"{
|
||||
@ -1970,7 +1943,7 @@ bool QDBusConnectionPrivate::send(const QDBusMessage& message)
|
||||
class QDBusBlockingCallWatcher
|
||||
{
|
||||
public:
|
||||
QDBusBlockingCallWatcher(const QDBusMessage &message)
|
||||
Q_NODISCARD_CTOR QDBusBlockingCallWatcher(const QDBusMessage &message)
|
||||
: m_message(message), m_maxCallTimeoutMs(0)
|
||||
{
|
||||
#if defined(QT_NO_DEBUG)
|
||||
@ -2428,8 +2401,8 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
|
||||
connector->connectAllSignals(node->obj);
|
||||
}
|
||||
|
||||
connect(connector, SIGNAL(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
|
||||
this, SLOT(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
|
||||
connect(connector, &QDBusAdaptorConnector::relaySignal, this,
|
||||
&QDBusConnectionPrivate::relaySignal,
|
||||
Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection));
|
||||
}
|
||||
}
|
||||
@ -2678,6 +2651,28 @@ void QDBusConnectionPrivate::postEventToThread(int action, QObject *object, QEve
|
||||
QDBusLockerBase::reportThreadAction(action, QDBusLockerBase::AfterPost, this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable dispatch of D-Bus events for this connection, but only after
|
||||
* context's thread's event loop has started and processed any already
|
||||
* pending events. The event dispatch is then enabled in the DBus aux thread.
|
||||
*/
|
||||
void QDBusConnectionPrivate::enableDispatchDelayed(QObject *context)
|
||||
{
|
||||
ref.ref();
|
||||
QMetaObject::invokeMethod(
|
||||
context,
|
||||
[this]() {
|
||||
// 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);
|
||||
if (!ref.deref())
|
||||
deleteLater();
|
||||
},
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
|
@ -76,11 +76,8 @@ static const char peerInterfaceXml[] =
|
||||
static QString generateSubObjectXml(QObject *object)
|
||||
{
|
||||
QString retval;
|
||||
const QObjectList &objs = object->children();
|
||||
QObjectList::ConstIterator it = objs.constBegin();
|
||||
QObjectList::ConstIterator end = objs.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QString name = (*it)->objectName();
|
||||
for (const QObject *child : object->children()) {
|
||||
QString name = child->objectName();
|
||||
if (!name.isEmpty() && QDBusUtil::isValidPartOfObjectPath(name))
|
||||
retval += " <node name=\""_L1 + name + "\"/>\n"_L1;
|
||||
}
|
||||
@ -116,20 +113,22 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
(connector = qDBusFindAdaptorConnector(node.obj))) {
|
||||
|
||||
// trasverse every adaptor in this object
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin();
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator end = connector->adaptors.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
// add the interface:
|
||||
QString ifaceXml = QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(it->adaptor);
|
||||
QString ifaceXml =
|
||||
QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(adaptorData.adaptor);
|
||||
if (ifaceXml.isEmpty()) {
|
||||
// add the interface's contents:
|
||||
ifaceXml += qDBusGenerateMetaObjectXml(QString::fromLatin1(it->interface),
|
||||
it->adaptor->metaObject(),
|
||||
&QDBusAbstractAdaptor::staticMetaObject,
|
||||
QDBusConnection::ExportScriptableContents
|
||||
| QDBusConnection::ExportNonScriptableContents);
|
||||
ifaceXml += qDBusGenerateMetaObjectXml(
|
||||
QString::fromLatin1(adaptorData.interface),
|
||||
adaptorData.adaptor->metaObject(),
|
||||
&QDBusAbstractAdaptor::staticMetaObject,
|
||||
QDBusConnection::ExportScriptableContents
|
||||
| QDBusConnection::ExportNonScriptableContents);
|
||||
|
||||
QDBusAbstractAdaptorPrivate::saveIntrospectionXml(it->adaptor, ifaceXml);
|
||||
QDBusAbstractAdaptorPrivate::saveIntrospectionXml(adaptorData.adaptor,
|
||||
ifaceXml);
|
||||
}
|
||||
|
||||
xml_data += ifaceXml;
|
||||
@ -151,13 +150,10 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
xml_data += generateSubObjectXml(node.obj);
|
||||
} else {
|
||||
// generate from the object tree
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it =
|
||||
node.children.constBegin();
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end =
|
||||
node.children.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
if (it->obj || !it->children.isEmpty())
|
||||
xml_data += " <node name=\""_L1 + it->name + "\"/>\n"_L1;
|
||||
for (const QDBusConnectionPrivate::ObjectTreeNode &node : node.children) {
|
||||
if (node.obj || !node.children.isEmpty())
|
||||
xml_data += " <node name=\""_L1 + node.name + "\"/>\n"_L1;
|
||||
}
|
||||
}
|
||||
|
||||
xml_data += "</node>\n"_L1;
|
||||
@ -195,7 +191,7 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
QString interface_name = msg.arguments().at(0).toString();
|
||||
QByteArray property_name = msg.arguments().at(1).toString().toUtf8();
|
||||
|
||||
QDBusAdaptorConnector *connector;
|
||||
const QDBusAdaptorConnector *connector;
|
||||
QVariant value;
|
||||
bool interfaceFound = false;
|
||||
if (node.flags & QDBusConnection::ExportAdaptors &&
|
||||
@ -204,12 +200,11 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
// find the class that implements interface_name or try until we've found the property
|
||||
// in case of an empty interface
|
||||
if (interface_name.isEmpty()) {
|
||||
for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
|
||||
end = connector->adaptors.constEnd(); it != end; ++it) {
|
||||
const QMetaObject *mo = it->adaptor->metaObject();
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData : connector->adaptors) {
|
||||
const QMetaObject *mo = adaptorData.adaptor->metaObject();
|
||||
int pidx = mo->indexOfProperty(property_name);
|
||||
if (pidx != -1) {
|
||||
value = mo->property(pidx).read(it->adaptor);
|
||||
value = mo->property(pidx).read(adaptorData.adaptor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -332,14 +327,14 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant
|
||||
return PropertyWriteFailed;
|
||||
}
|
||||
|
||||
value = other;
|
||||
value = std::move(other);
|
||||
}
|
||||
|
||||
if (mp.metaType() == QMetaType::fromType<QDBusVariant>())
|
||||
value = QVariant::fromValue(QDBusVariant(value));
|
||||
|
||||
// the property type here should match
|
||||
return mp.write(obj, value) ? PropertyWriteSuccess : PropertyWriteFailed;
|
||||
return mp.write(obj, std::move(value)) ? PropertyWriteSuccess : PropertyWriteFailed;
|
||||
}
|
||||
|
||||
QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node,
|
||||
@ -361,9 +356,9 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
// find the class that implements interface_name or try until we've found the property
|
||||
// in case of an empty interface
|
||||
if (interface_name.isEmpty()) {
|
||||
for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
|
||||
end = connector->adaptors.constEnd(); it != end; ++it) {
|
||||
int status = writeProperty(it->adaptor, property_name, value);
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
int status = writeProperty(adaptorData.adaptor, property_name, value);
|
||||
if (status == PropertyNotFound)
|
||||
continue;
|
||||
return propertyWriteReply(msg, interface_name, property_name, status);
|
||||
@ -401,10 +396,8 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
// unite two QVariantMaps, but don't generate duplicate keys
|
||||
static QVariantMap &operator+=(QVariantMap &lhs, const QVariantMap &rhs)
|
||||
{
|
||||
QVariantMap::ConstIterator it = rhs.constBegin(),
|
||||
end = rhs.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
lhs.insert(it.key(), it.value());
|
||||
for (const auto &[key, value] : rhs.asKeyValueRange())
|
||||
lhs.insert(key, value);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
@ -461,9 +454,10 @@ QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &n
|
||||
|
||||
if (interface_name.isEmpty()) {
|
||||
// iterate over all interfaces
|
||||
for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
|
||||
end = connector->adaptors.constEnd(); it != end; ++it) {
|
||||
result += readAllProperties(it->adaptor, QDBusConnection::ExportAllProperties);
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
result += readAllProperties(adaptorData.adaptor,
|
||||
QDBusConnection::ExportAllProperties);
|
||||
}
|
||||
} else {
|
||||
// find the class that implements interface_name
|
||||
|
@ -206,10 +206,8 @@ inline void QDBusMarshaller::append(const QStringList &arg)
|
||||
|
||||
QDBusMarshaller sub(capabilities);
|
||||
open(sub, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING);
|
||||
QStringList::ConstIterator it = arg.constBegin();
|
||||
QStringList::ConstIterator end = arg.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
sub.append(*it);
|
||||
for (const QString &s : arg)
|
||||
sub.append(s);
|
||||
// don't call sub.close(): it auto-closes
|
||||
}
|
||||
|
||||
|
@ -155,14 +155,12 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
|
||||
d_ptr->parametersValidated = true;
|
||||
|
||||
QDBusMarshaller marshaller(capabilities);
|
||||
QVariantList::ConstIterator it = d_ptr->arguments.constBegin();
|
||||
QVariantList::ConstIterator cend = d_ptr->arguments.constEnd();
|
||||
q_dbus_message_iter_init_append(msg, &marshaller.iterator);
|
||||
if (!d_ptr->message.isEmpty())
|
||||
// prepend the error message
|
||||
marshaller.append(d_ptr->message);
|
||||
for ( ; it != cend; ++it)
|
||||
marshaller.appendVariantInternal(*it);
|
||||
for (const QVariant &argument : std::as_const(d_ptr->arguments))
|
||||
marshaller.appendVariantInternal(argument);
|
||||
|
||||
// check if everything is ok
|
||||
if (marshaller.ok)
|
||||
@ -239,10 +237,8 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
|
||||
|
||||
// determine if we are carrying any complex types
|
||||
QString computedSignature;
|
||||
QVariantList::ConstIterator it = asSent.d_ptr->arguments.constBegin();
|
||||
QVariantList::ConstIterator end = asSent.d_ptr->arguments.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QMetaType id = it->metaType();
|
||||
for (const QVariant &argument : std::as_const(asSent.d_ptr->arguments)) {
|
||||
QMetaType id = argument.metaType();
|
||||
const char *signature = QDBusMetaType::typeToSignature(id);
|
||||
if ((id.id() != QMetaType::QStringList && id.id() != QMetaType::QByteArray &&
|
||||
qstrlen(signature) != 1) || id == QMetaType::fromType<QDBusVariant>()) {
|
||||
@ -804,12 +800,10 @@ static QDebug operator<<(QDebug dbg, QDBusMessage::MessageType t)
|
||||
static void debugVariantList(QDebug dbg, const QVariantList &list)
|
||||
{
|
||||
bool first = true;
|
||||
QVariantList::ConstIterator it = list.constBegin();
|
||||
QVariantList::ConstIterator end = list.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const QVariant &elem : list) {
|
||||
if (!first)
|
||||
dbg.nospace() << ", ";
|
||||
dbg.nospace() << qPrintable(QDBusUtil::argumentToString(*it));
|
||||
dbg.nospace() << qPrintable(QDBusUtil::argumentToString(elem));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,9 @@ private:
|
||||
QByteArray name;
|
||||
};
|
||||
|
||||
QMap<QByteArray, Method> signals_;
|
||||
QMap<QByteArray, Method> methods;
|
||||
using MethodMap = QMap<QByteArray, Method>;
|
||||
MethodMap signals_;
|
||||
MethodMap methods;
|
||||
QMap<QByteArray, Property> properties;
|
||||
|
||||
const QDBusIntrospection::Interface *data;
|
||||
@ -70,7 +71,7 @@ private:
|
||||
void parseSignals();
|
||||
void parseProperties();
|
||||
|
||||
static qsizetype aggregateParameterCount(const QMap<QByteArray, Method> &map);
|
||||
static qsizetype aggregateParameterCount(const MethodMap &map);
|
||||
};
|
||||
|
||||
static const qsizetype intsPerProperty = 2;
|
||||
@ -208,10 +209,7 @@ void QDBusMetaObjectGenerator::parseMethods()
|
||||
// Add cloned methods when the remote object has return types
|
||||
//
|
||||
|
||||
QDBusIntrospection::Methods::ConstIterator method_it = data->methods.constBegin();
|
||||
QDBusIntrospection::Methods::ConstIterator method_end = data->methods.constEnd();
|
||||
for ( ; method_it != method_end; ++method_it) {
|
||||
const QDBusIntrospection::Method &m = *method_it;
|
||||
for (const QDBusIntrospection::Method &m : std::as_const(data->methods)) {
|
||||
Method mm;
|
||||
|
||||
mm.name = m.name.toLatin1();
|
||||
@ -284,10 +282,7 @@ void QDBusMetaObjectGenerator::parseMethods()
|
||||
|
||||
void QDBusMetaObjectGenerator::parseSignals()
|
||||
{
|
||||
QDBusIntrospection::Signals::ConstIterator signal_it = data->signals_.constBegin();
|
||||
QDBusIntrospection::Signals::ConstIterator signal_end = data->signals_.constEnd();
|
||||
for ( ; signal_it != signal_end; ++signal_it) {
|
||||
const QDBusIntrospection::Signal &s = *signal_it;
|
||||
for (const QDBusIntrospection::Signal &s : std::as_const(data->signals_)) {
|
||||
Method mm;
|
||||
|
||||
mm.name = s.name.toLatin1();
|
||||
@ -331,10 +326,7 @@ void QDBusMetaObjectGenerator::parseSignals()
|
||||
|
||||
void QDBusMetaObjectGenerator::parseProperties()
|
||||
{
|
||||
QDBusIntrospection::Properties::ConstIterator prop_it = data->properties.constBegin();
|
||||
QDBusIntrospection::Properties::ConstIterator prop_end = data->properties.constEnd();
|
||||
for ( ; prop_it != prop_end; ++prop_it) {
|
||||
const QDBusIntrospection::Property &p = *prop_it;
|
||||
for (const QDBusIntrospection::Property &p : std::as_const(data->properties)) {
|
||||
Property mp;
|
||||
Type type = findType(p.type.toLatin1(), p.annotations);
|
||||
if (type.id == QMetaType::UnknownType)
|
||||
@ -360,14 +352,11 @@ void QDBusMetaObjectGenerator::parseProperties()
|
||||
// Returns the sum of all parameters (including return type) for the given
|
||||
// \a map of methods. This is needed for calculating the size of the methods'
|
||||
// parameter type/name meta-data.
|
||||
qsizetype QDBusMetaObjectGenerator::aggregateParameterCount(const QMap<QByteArray, Method> &map)
|
||||
qsizetype QDBusMetaObjectGenerator::aggregateParameterCount(const MethodMap &map)
|
||||
{
|
||||
qsizetype sum = 0;
|
||||
QMap<QByteArray, Method>::const_iterator it;
|
||||
for (it = map.constBegin(); it != map.constEnd(); ++it) {
|
||||
const Method &m = it.value();
|
||||
for (const Method &m : map)
|
||||
sum += m.inputTypes.size() + qMax(qsizetype(1), m.outputTypes.size());
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@ -391,7 +380,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
- methods.size(); // ditto
|
||||
|
||||
QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data());
|
||||
static_assert(QMetaObjectPrivate::OutputRevision == 11, "QtDBus meta-object generator should generate the same version as moc");
|
||||
static_assert(QMetaObjectPrivate::OutputRevision == 12, "QtDBus meta-object generator should generate the same version as moc");
|
||||
header->revision = QMetaObjectPrivate::OutputRevision;
|
||||
header->className = 0;
|
||||
header->classInfoCount = 0;
|
||||
@ -415,10 +404,14 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
qsizetype data_size = idata.size() +
|
||||
(header->methodCount * (QMetaObjectPrivate::IntsPerMethod+intsPerMethod)) + methodParametersDataSize +
|
||||
(header->propertyCount * (QMetaObjectPrivate::IntsPerProperty+intsPerProperty));
|
||||
for (const Method &mm : std::as_const(signals_))
|
||||
data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size();
|
||||
for (const Method &mm : std::as_const(methods))
|
||||
data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size();
|
||||
|
||||
// Signals must be added before other methods, to match moc.
|
||||
std::array<std::reference_wrapper<const MethodMap>, 2> methodMaps = { signals_, methods };
|
||||
|
||||
for (const auto &methodMap : methodMaps) {
|
||||
for (const Method &mm : methodMap.get())
|
||||
data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size();
|
||||
}
|
||||
idata.resize(data_size + 1);
|
||||
|
||||
QMetaStringTable strings(className.toLatin1());
|
||||
@ -431,9 +424,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
|
||||
qsizetype totalMetaTypeCount = properties.size();
|
||||
++totalMetaTypeCount; // + 1 for metatype of dynamic metaobject
|
||||
for (const auto& methodContainer: {signals_, methods}) {
|
||||
for (const auto& method: methodContainer) {
|
||||
qsizetype argc = method.inputTypes.size() + qMax(qsizetype(0), method.outputTypes.size() - 1);
|
||||
for (const auto &methodMap : methodMaps) {
|
||||
for (const Method &mm : methodMap.get()) {
|
||||
qsizetype argc = mm.inputTypes.size() + qMax(qsizetype(0), mm.outputTypes.size() - 1);
|
||||
totalMetaTypeCount += argc + 1;
|
||||
}
|
||||
}
|
||||
@ -442,13 +435,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
|
||||
// add each method:
|
||||
qsizetype currentMethodMetaTypeOffset = properties.size() + 1;
|
||||
for (int x = 0; x < 2; ++x) {
|
||||
// Signals must be added before other methods, to match moc.
|
||||
QMap<QByteArray, Method> &map = (x == 0) ? signals_ : methods;
|
||||
for (QMap<QByteArray, Method>::ConstIterator it = map.constBegin();
|
||||
it != map.constEnd(); ++it) {
|
||||
const Method &mm = it.value();
|
||||
|
||||
for (const auto &methodMap : methodMaps) {
|
||||
for (const Method &mm : methodMap.get()) {
|
||||
qsizetype argc = mm.inputTypes.size() + qMax(qsizetype(0), mm.outputTypes.size() - 1);
|
||||
|
||||
idata[offset++] = strings.enter(mm.name);
|
||||
@ -514,12 +503,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
|
||||
// add each property
|
||||
signatureOffset = header->propertyDBusData;
|
||||
for (QMap<QByteArray, Property>::ConstIterator it = properties.constBegin();
|
||||
it != properties.constEnd(); ++it) {
|
||||
const Property &mp = it.value();
|
||||
|
||||
for (const auto &[name, mp] : std::as_const(properties).asKeyValueRange()) {
|
||||
// form is name, typeinfo, flags
|
||||
idata[offset++] = strings.enter(it.key()); // name
|
||||
idata[offset++] = strings.enter(name);
|
||||
Q_ASSERT(mp.type != QMetaType::UnknownType);
|
||||
idata[offset++] = mp.type;
|
||||
idata[offset++] = mp.flags;
|
||||
|
@ -99,9 +99,13 @@ void QDBusMetaTypeId::init()
|
||||
}
|
||||
}
|
||||
|
||||
using QDBusCustomTypeHash = QHash<int, QDBusCustomTypeInfo>;
|
||||
Q_GLOBAL_STATIC(QDBusCustomTypeHash, customTypes)
|
||||
Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
|
||||
struct QDBusCustomTypes
|
||||
{
|
||||
QReadWriteLock lock;
|
||||
QHash<int, QDBusCustomTypeInfo> hash;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(QDBusCustomTypes, customTypes)
|
||||
|
||||
/*!
|
||||
\class QDBusMetaType
|
||||
@ -182,12 +186,15 @@ void QDBusMetaType::registerMarshallOperators(QMetaType metaType, MarshallFuncti
|
||||
DemarshallFunction df)
|
||||
{
|
||||
int id = metaType.id();
|
||||
auto *ct = customTypes();
|
||||
if (id < 0 || !mf || !df || !ct)
|
||||
if (id < 0 || !mf || !df)
|
||||
return; // error!
|
||||
|
||||
QWriteLocker locker(customTypesLock());
|
||||
QDBusCustomTypeInfo &info = (*ct)[id];
|
||||
auto *ct = customTypes();
|
||||
if (!ct)
|
||||
return;
|
||||
|
||||
QWriteLocker locker(&ct->lock);
|
||||
QDBusCustomTypeInfo &info = ct->hash[id];
|
||||
info.marshall = mf;
|
||||
info.demarshall = df;
|
||||
}
|
||||
@ -200,15 +207,19 @@ void QDBusMetaType::registerMarshallOperators(QMetaType metaType, MarshallFuncti
|
||||
*/
|
||||
bool QDBusMetaType::marshall(QDBusArgument &arg, QMetaType metaType, const void *data)
|
||||
{
|
||||
auto *ct = customTypes();
|
||||
if (!ct)
|
||||
return false;
|
||||
|
||||
int id = metaType.id();
|
||||
QDBusMetaTypeId::init();
|
||||
|
||||
MarshallFunction mf;
|
||||
{
|
||||
QReadLocker locker(customTypesLock());
|
||||
auto *ct = customTypes();
|
||||
auto it = ct->constFind(id);
|
||||
if (it == ct->cend())
|
||||
QReadLocker locker(&ct->lock);
|
||||
|
||||
auto it = ct->hash.constFind(id);
|
||||
if (it == ct->hash.cend())
|
||||
return false; // non-existent
|
||||
|
||||
const QDBusCustomTypeInfo &info = *it;
|
||||
@ -231,15 +242,19 @@ bool QDBusMetaType::marshall(QDBusArgument &arg, QMetaType metaType, const void
|
||||
*/
|
||||
bool QDBusMetaType::demarshall(const QDBusArgument &arg, QMetaType metaType, void *data)
|
||||
{
|
||||
auto *ct = customTypes();
|
||||
if (!ct)
|
||||
return false;
|
||||
|
||||
int id = metaType.id();
|
||||
QDBusMetaTypeId::init();
|
||||
|
||||
DemarshallFunction df;
|
||||
{
|
||||
QReadLocker locker(customTypesLock());
|
||||
auto *ct = customTypes();
|
||||
auto it = ct->constFind(id);
|
||||
if (it == ct->cend())
|
||||
QReadLocker locker(&ct->lock);
|
||||
|
||||
auto it = ct->hash.constFind(id);
|
||||
if (it == ct->hash.cend())
|
||||
return false; // non-existent
|
||||
|
||||
const QDBusCustomTypeInfo &info = *it;
|
||||
@ -357,8 +372,11 @@ QMetaType QDBusMetaType::signatureToMetaType(const char *signature)
|
||||
void QDBusMetaType::registerCustomType(QMetaType type, const QByteArray &signature)
|
||||
{
|
||||
auto *ct = customTypes();
|
||||
QWriteLocker locker(customTypesLock());
|
||||
auto &info = (*ct)[type.id()];
|
||||
if (!ct)
|
||||
return;
|
||||
|
||||
QWriteLocker locker(&ct->lock);
|
||||
auto &info = ct->hash[type.id()];
|
||||
info.signature = signature;
|
||||
// note how marshall/demarshall are not set, the type is never used at runtime
|
||||
}
|
||||
@ -430,10 +448,13 @@ const char *QDBusMetaType::typeToSignature(QMetaType type)
|
||||
|
||||
// try the database
|
||||
auto *ct = customTypes();
|
||||
if (!ct)
|
||||
return nullptr;
|
||||
|
||||
{
|
||||
QReadLocker locker(customTypesLock());
|
||||
auto it = ct->constFind(type.id());
|
||||
if (it == ct->end())
|
||||
QReadLocker locker(&ct->lock);
|
||||
auto it = ct->hash.constFind(type.id());
|
||||
if (it == ct->hash.end())
|
||||
return nullptr;
|
||||
|
||||
const QDBusCustomTypeInfo &info = *it;
|
||||
@ -453,8 +474,8 @@ const char *QDBusMetaType::typeToSignature(QMetaType type)
|
||||
QByteArray signature = QDBusArgumentPrivate::createSignature(type.id());
|
||||
|
||||
// re-acquire lock
|
||||
QWriteLocker locker(customTypesLock());
|
||||
info = &(*ct)[type.id()];
|
||||
QWriteLocker locker(&ct->lock);
|
||||
info = &ct->hash[type.id()];
|
||||
info->signature = signature;
|
||||
}
|
||||
return info->signature;
|
||||
|
@ -28,18 +28,17 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
struct QDBusMetaTypeId
|
||||
{
|
||||
static QMetaType message(); // QDBusMessage
|
||||
static QMetaType argument(); // QDBusArgument
|
||||
static QMetaType variant(); // QDBusVariant
|
||||
static QMetaType objectpath(); // QDBusObjectPath
|
||||
static QMetaType signature(); // QDBusSignature
|
||||
static QMetaType error(); // QDBusError
|
||||
static QMetaType unixfd(); // QDBusUnixFileDescriptor
|
||||
namespace QDBusMetaTypeId {
|
||||
QMetaType message(); // QDBusMessage
|
||||
QMetaType argument(); // QDBusArgument
|
||||
QMetaType variant(); // QDBusVariant
|
||||
QMetaType objectpath(); // QDBusObjectPath
|
||||
QMetaType signature(); // QDBusSignature
|
||||
QMetaType error(); // QDBusError
|
||||
QMetaType unixfd(); // QDBusUnixFileDescriptor
|
||||
|
||||
static void init();
|
||||
};
|
||||
void init();
|
||||
}; // namespace QDBusMetaTypeId
|
||||
|
||||
inline QMetaType QDBusMetaTypeId::message()
|
||||
{ return QMetaType::fromType<QDBusMessage>(); }
|
||||
|
@ -117,10 +117,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<QMet
|
||||
metaTypes.append(QMetaType()); // return type
|
||||
int inputCount = 0;
|
||||
bool seenMessage = false;
|
||||
QList<QByteArray>::ConstIterator it = parameterTypes.constBegin();
|
||||
QList<QByteArray>::ConstIterator end = parameterTypes.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QByteArray type = *it;
|
||||
for (QByteArray type : parameterTypes) {
|
||||
if (type.endsWith('*')) {
|
||||
errorMsg = "Pointers are not supported: "_L1 + QLatin1StringView(type);
|
||||
return -1;
|
||||
|
@ -474,7 +474,9 @@ QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, Q
|
||||
d->watcherHelper = new QDBusPendingCallWatcherHelper;
|
||||
if (d->replyMessage.type() != QDBusMessage::InvalidMessage) {
|
||||
// cause a signal emission anyways
|
||||
QMetaObject::invokeMethod(d->watcherHelper, "finished", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(d->watcherHelper,
|
||||
&QDBusPendingCallWatcherHelper::finished,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
d->watcherHelper->add(this);
|
||||
|
@ -93,7 +93,7 @@ struct QDBusReadLocker: QDBusLockerBase
|
||||
{
|
||||
QDBusConnectionPrivate *self;
|
||||
ThreadAction action;
|
||||
inline QDBusReadLocker(ThreadAction a, QDBusConnectionPrivate *s)
|
||||
Q_NODISCARD_CTOR QDBusReadLocker(ThreadAction a, QDBusConnectionPrivate *s)
|
||||
: self(s), action(a)
|
||||
{
|
||||
reportThreadAction(action, BeforeLock, self);
|
||||
@ -113,7 +113,7 @@ struct QDBusWriteLocker: QDBusLockerBase
|
||||
{
|
||||
QDBusConnectionPrivate *self;
|
||||
ThreadAction action;
|
||||
inline QDBusWriteLocker(ThreadAction a, QDBusConnectionPrivate *s)
|
||||
Q_NODISCARD_CTOR QDBusWriteLocker(ThreadAction a, QDBusConnectionPrivate *s)
|
||||
: self(s), action(a)
|
||||
{
|
||||
reportThreadAction(action, BeforeLock, self);
|
||||
|
Reference in New Issue
Block a user