diff options
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/doc/qtdbus.qdocconf | 2 | ||||
-rw-r--r-- | src/dbus/qdbusargument.h | 17 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 17 | ||||
-rw-r--r-- | src/dbus/qdbuspendingreply.cpp | 28 | ||||
-rw-r--r-- | src/dbus/qdbuspendingreply.h | 4 |
5 files changed, 58 insertions, 10 deletions
diff --git a/src/dbus/doc/qtdbus.qdocconf b/src/dbus/doc/qtdbus.qdocconf index 7a58dada63..1ff4c0d6c7 100644 --- a/src/dbus/doc/qtdbus.qdocconf +++ b/src/dbus/doc/qtdbus.qdocconf @@ -36,7 +36,7 @@ qhp.qtdbus.file = qtdbus.qhp # Namespace for the output file. This namespace is used to distinguish between # different documentation files in Creator/Assistant. -qhp.qtdbus.namespace = org.qt-project.qtdbus.501 +qhp.qtdbus.namespace = org.qt-project.qtdbus.510 # Title for the package, will be the main title for the package in # Assistant/Creator. diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index c0bce586ac..dc79843d1e 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -397,6 +397,23 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map) return arg; } +template <typename T1, typename T2> +inline QDBusArgument &operator<<(QDBusArgument &arg, const QPair<T1, T2> &pair) +{ + arg.beginStructure(); + arg << pair.first << pair.second; + arg.endStructure(); + return arg; +} + +template <typename T1, typename T2> +inline const QDBusArgument &operator>>(const QDBusArgument &arg, QPair<T1, T2> &pair) +{ + arg.beginStructure(); + arg >> pair.first >> pair.second; + arg.endStructure(); + return arg; +} QT_END_NAMESPACE diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 325cee6bae..bc49d6816e 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -2224,6 +2224,19 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) return signalHooks.erase(it); } + +static void cleanupDeletedNodes(QDBusConnectionPrivate::ObjectTreeNode &parent) +{ + QMutableVectorIterator<QDBusConnectionPrivate::ObjectTreeNode> it(parent.children); + while (it.hasNext()) { + QDBusConnectionPrivate::ObjectTreeNode& node = it.next(); + if (node.obj == 0 && node.children.isEmpty()) + it.remove(); + else + cleanupDeletedNodes(node); + } +} + void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node) { connect(node->obj, SIGNAL(destroyed(QObject*)), SLOT(objectDestroyed(QObject*)), @@ -2247,6 +2260,10 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node) this, SLOT(relaySignal(QObject*,const QMetaObject*,int,QVariantList)), Qt::DirectConnection); } + + static int counter = 0; + if ((++counter % 20) == 0) + cleanupDeletedNodes(rootNode); } void QDBusConnectionPrivate::connectRelay(const QString &service, diff --git a/src/dbus/qdbuspendingreply.cpp b/src/dbus/qdbuspendingreply.cpp index cf99bb692c..c0e24bee06 100644 --- a/src/dbus/qdbuspendingreply.cpp +++ b/src/dbus/qdbuspendingreply.cpp @@ -185,6 +185,11 @@ function's return value is undefined (will probably cause an assertion failure), so it is important to verify that the processing is finished and the reply is valid. + + If the reply does not contain an argument at position \a index or if the + reply was an error, this function returns an invalid QVariant. Since D-Bus + messages can never contain invalid QVariants, this return can be used to + detect an error condition. */ /*! @@ -197,6 +202,11 @@ Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed. + + If the reply does not contain an argument at position \c Index or if the + reply was an error, this function returns a \c Type object that is default + constructed, which may be indistinguishable from a valid value. To reliably + determine whether the message was an error, use isError(). */ /*! @@ -211,6 +221,10 @@ Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed. + + If the reply is an error reply, this function returns a default-constructed + \c T1 object, which may be indistinguishable from a valid value. To + reliably determine whether the message was an error, use isError(). */ /*! @@ -225,6 +239,10 @@ Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed. + + If the reply is an error reply, this function returns a default-constructed + \c T1 object, which may be indistinguishable from a valid value. To + reliably determine whether the message was an error, use isError(). */ /*! @@ -260,14 +278,12 @@ void QDBusPendingReplyData::assign(const QDBusMessage &message) QVariant QDBusPendingReplyData::argumentAt(int index) const { - if (d) - d->waitForFinished(); // bypasses "const" + if (!d) + return QVariant(); - Q_ASSERT_X(d && index >= 0 && index < d->replyMessage.arguments().count(), - "QDBusPendingReply::argumentAt", - "Index out of bounds"); + d->waitForFinished(); // bypasses "const" - return d->replyMessage.arguments().at(index); + return d->replyMessage.arguments().value(index); } void QDBusPendingReplyData::setMetaTypes(int count, const int *types) diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h index 89cd846bf8..c7a030d78f 100644 --- a/src/dbus/qdbuspendingreply.h +++ b/src/dbus/qdbuspendingreply.h @@ -168,9 +168,7 @@ public: template<int Index> inline const typename Select<Index>::Type argumentAt() const { - // static assert? - Q_ASSERT_X(Index < count() && Index >= 0, "QDBusPendingReply::argumentAt", - "Index out of bounds"); + Q_STATIC_ASSERT_X(Index >= 0 && Index < Count, "Index out of bounds"); typedef typename Select<Index>::Type ResultType; return qdbus_cast<ResultType>(argumentAt(Index), 0); } |