summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-03-20 23:30:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-20 23:30:31 +0100
commite5a11fbb3251a98fafd6bebf0b6fc366acb19088 (patch)
tree8e1bd6704205307e0a23484221ea1bb67a9f411e /src/dbus
parent0646d1131b4bc65cdd9af29f4ce00fdd2398a3df (diff)
parent76c0be34cd4ff4564693162fa7528463e23ce9d8 (diff)
Merge "Merge branch 'dev' into stable" into refs/staging/stable
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/qdbus_symbols_p.h2
-rw-r--r--src/dbus/qdbusabstractadaptor.h4
-rw-r--r--src/dbus/qdbusabstractinterface.cpp21
-rw-r--r--src/dbus/qdbusabstractinterface.h4
-rw-r--r--src/dbus/qdbusargument.h21
-rw-r--r--src/dbus/qdbusconnection.cpp47
-rw-r--r--src/dbus/qdbusconnection.h4
-rw-r--r--src/dbus/qdbusconnection_p.h12
-rw-r--r--src/dbus/qdbusconnectioninterface.h4
-rw-r--r--src/dbus/qdbuscontext.h4
-rw-r--r--src/dbus/qdbuserror.cpp2
-rw-r--r--src/dbus/qdbuserror.h4
-rw-r--r--src/dbus/qdbusextratypes.h4
-rw-r--r--src/dbus/qdbusintegrator.cpp93
-rw-r--r--src/dbus/qdbusintegrator_p.h2
-rw-r--r--src/dbus/qdbusinterface.h4
-rw-r--r--src/dbus/qdbusintrospection_p.h2
-rw-r--r--src/dbus/qdbusmacros.h2
-rw-r--r--src/dbus/qdbusmessage.h4
-rw-r--r--src/dbus/qdbusmetaobject.cpp18
-rw-r--r--src/dbus/qdbusmetatype.cpp6
-rw-r--r--src/dbus/qdbusmetatype.h4
-rw-r--r--src/dbus/qdbuspendingcall.h4
-rw-r--r--src/dbus/qdbuspendingreply.cpp28
-rw-r--r--src/dbus/qdbuspendingreply.h14
-rw-r--r--src/dbus/qdbusreply.h8
-rw-r--r--src/dbus/qdbusserver.h4
-rw-r--r--src/dbus/qdbusservicewatcher.h4
-rw-r--r--src/dbus/qdbusunixfiledescriptor.h4
-rw-r--r--src/dbus/qdbusutil_p.h4
-rw-r--r--src/dbus/qdbusvirtualobject.cpp5
-rw-r--r--src/dbus/qdbusvirtualobject.h4
32 files changed, 182 insertions, 165 deletions
diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h
index c1e36b0175..9e81bac30e 100644
--- a/src/dbus/qdbus_symbols_p.h
+++ b/src/dbus/qdbus_symbols_p.h
@@ -176,7 +176,7 @@ DEFINEFUNC(dbus_bool_t , dbus_timeout_handle, (DBusTimeout *timeout),
DEFINEFUNC(dbus_bool_t , dbus_watch_get_enabled, (DBusWatch *watch),
(watch), return)
-DEFINEFUNC(int , dbus_watch_get_fd, (DBusWatch *watch),
+DEFINEFUNC(int , dbus_watch_get_unix_fd, (DBusWatch *watch),
(watch), return)
DEFINEFUNC(unsigned int , dbus_watch_get_flags, (DBusWatch *watch),
(watch), return)
diff --git a/src/dbus/qdbusabstractadaptor.h b/src/dbus/qdbusabstractadaptor.h
index 1f414b0d92..2a32344de5 100644
--- a/src/dbus/qdbusabstractadaptor.h
+++ b/src/dbus/qdbusabstractadaptor.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -72,8 +70,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp
index 2a8681d1d7..53def1beb6 100644
--- a/src/dbus/qdbusabstractinterface.cpp
+++ b/src/dbus/qdbusabstractinterface.cpp
@@ -513,7 +513,7 @@ QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList(const QString
not indicate that the executed call succeeded. If it fails,
the \a errorMethod is called. If the queueing failed, this
function returns false and no slot will be called.
-
+
The \a returnMethod must have as its parameters the types returned
by the function call. Optionally, it may have a QDBusMessage
parameter as its last or only parameter. The \a errorMethod must
@@ -609,9 +609,22 @@ void QDBusAbstractInterface::disconnectNotify(const QMetaMethod &signal)
return;
QDBusConnectionPrivate *conn = d->connectionPrivate();
- if (conn)
- conn->disconnectRelay(d->service, d->path, d->interface,
- this, signal);
+ if (conn && signal.isValid() && !isSignalConnected(signal))
+ return conn->disconnectRelay(d->service, d->path, d->interface,
+ this, signal);
+ if (!conn)
+ return;
+
+ // wildcard disconnecting, we need to figure out which of our signals are
+ // no longer connected to anything
+ const QMetaObject *mo = metaObject();
+ int midx = QObject::staticMetaObject.methodCount();
+ const int end = mo->methodCount();
+ for ( ; midx < end; ++midx) {
+ QMetaMethod mm = mo->method(midx);
+ if (mm.methodType() == QMetaMethod::Signal && !isSignalConnected(mm))
+ conn->disconnectRelay(d->service, d->path, d->interface, this, mm);
+ }
}
/*!
diff --git a/src/dbus/qdbusabstractinterface.h b/src/dbus/qdbusabstractinterface.h
index ae094c000b..8f014ce151 100644
--- a/src/dbus/qdbusabstractinterface.h
+++ b/src/dbus/qdbusabstractinterface.h
@@ -53,8 +53,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -161,7 +159,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index c0bce586ac..a3a6f990fc 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -55,8 +55,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -397,10 +395,25 @@ 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;
+}
-QT_END_NAMESPACE
+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_HEADER
+QT_END_NAMESPACE
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index d576112f8d..74a3a752a5 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -803,13 +803,8 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis
return false;
if (options & QDBusConnectionPrivate::VirtualObject) {
- // technically the check for children needs to go even deeper
- if (options & SubPath) {
- foreach (const QDBusConnectionPrivate::ObjectTreeNode &child, node->children) {
- if (child.obj)
- return false;
- }
- }
+ if (options & SubPath && node->activeChildren)
+ return false;
} else {
if ((options & ExportChildObjects && !node->children.isEmpty()))
return false;
@@ -825,8 +820,8 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis
// if a virtual object occupies this path, return false
if (node->obj && (node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) {
- qDebug("Cannot register object at %s because QDBusVirtualObject handles all sub-paths.",
- qPrintable(path));
+ //qDebug("Cannot register object at %s because QDBusVirtualObject handles all sub-paths.",
+ // qPrintable(path));
return false;
}
@@ -840,12 +835,13 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis
// are we allowed to go deeper?
if (node->flags & ExportChildObjects) {
// we're not
- qDebug("Cannot register object at %s because %s exports its own child objects",
- qPrintable(path), qPrintable(pathComponents.at(i)));
+ //qDebug("Cannot register object at %s because %s exports its own child objects",
+ // qPrintable(path), qPrintable(pathComponents.at(i)));
return false;
}
} else {
// add entry
+ ++node->activeChildren;
node = node->children.insert(it, pathComponents.at(i));
}
@@ -883,35 +879,8 @@ void QDBusConnection::unregisterObject(const QString &path, UnregisterMode mode)
if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path))
return;
- QStringList pathComponents = path.split(QLatin1Char('/'));
QDBusWriteLocker locker(UnregisterObjectAction, d);
- QDBusConnectionPrivate::ObjectTreeNode *node = &d->rootNode;
- int i = 1;
-
- // find the object
- while (node) {
- if (pathComponents.count() == i || !path.compare(QLatin1String("/"))) {
- // found it
- node->obj = 0;
- node->flags = 0;
-
- if (mode == UnregisterTree) {
- // clear the sub-tree as well
- node->children.clear(); // can't disconnect the objects because we really don't know if they can
- // be found somewhere else in the path too
- }
-
- return;
- }
-
- QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it =
- std::lower_bound(node->children.begin(), node->children.end(), pathComponents.at(i));
- if (it == node->children.end() || it->name != pathComponents.at(i))
- break; // node not found
-
- node = it;
- ++i;
- }
+ d->unregisterObject(path, mode);
}
/*!
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index 35559ba37a..20a579f8d6 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -208,7 +206,5 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::VirtualObjectRegisterOptions)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index 2c3ddefc50..73c8dcf411 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -140,14 +140,16 @@ public:
{
typedef QVector<ObjectTreeNode> DataList;
- inline ObjectTreeNode() : obj(0), flags(0) { }
+ inline ObjectTreeNode() : obj(0), flags(0), activeChildren(0) { }
inline ObjectTreeNode(const QString &n) // intentionally implicit
- : name(n), obj(0), flags(0) { }
+ : name(n), obj(0), flags(0), activeChildren(0) { }
inline ~ObjectTreeNode() { }
inline bool operator<(const QString &other) const
{ return name < other; }
inline bool operator<(const QStringRef &other) const
{ return QStringRef(&name) < other; }
+ inline bool isActive() const
+ { return obj || activeChildren; }
QString name;
union {
@@ -155,6 +157,7 @@ public:
QDBusVirtualObject *treeNode;
};
int flags;
+ int activeChildren;
DataList children;
};
@@ -208,6 +211,7 @@ public:
const QString &name, const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot);
void registerObject(const ObjectTreeNode *node);
+ void unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode);
void connectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver, const QMetaMethod &signal);
@@ -340,8 +344,8 @@ public:
// in qdbusmisc.cpp
extern int qDBusParametersForMethod(const QMetaMethod &mm, QVector<int> &metaTypes);
#endif // QT_BOOTSTRAPPED
-extern int qDBusParametersForMethod(const QList<QByteArray> &parameters, QVector<int>& metaTypes);
-extern bool qDBusCheckAsyncTag(const char *tag);
+extern Q_DBUS_EXPORT int qDBusParametersForMethod(const QList<QByteArray> &parameters, QVector<int>& metaTypes);
+extern Q_DBUS_EXPORT bool qDBusCheckAsyncTag(const char *tag);
#ifndef QT_BOOTSTRAPPED
extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name);
extern QString qDBusInterfaceFromMetaObject(const QMetaObject *mo);
diff --git a/src/dbus/qdbusconnectioninterface.h b/src/dbus/qdbusconnectioninterface.h
index 6c45201445..b900d2a64c 100644
--- a/src/dbus/qdbusconnectioninterface.h
+++ b/src/dbus/qdbusconnectioninterface.h
@@ -49,8 +49,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -125,7 +123,5 @@ QT_END_NAMESPACE
Q_DECLARE_BUILTIN_METATYPE(UInt, QMetaType::UInt, QDBusConnectionInterface::RegisterServiceReply)
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbuscontext.h b/src/dbus/qdbuscontext.h
index 4578c30626..82dc7783bf 100644
--- a/src/dbus/qdbuscontext.h
+++ b/src/dbus/qdbuscontext.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -80,7 +78,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp
index d578bf7d76..f486c19fdc 100644
--- a/src/dbus/qdbuserror.cpp
+++ b/src/dbus/qdbuserror.cpp
@@ -72,7 +72,7 @@ for ($j = 0; $j < $i; ++$j) {
}
print "0\n};\n";
===== PERL SCRIPT ====
-
+
* The input data is as follows:
other
org.freedesktop.DBus.Error.Failed
diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h
index ae738d0860..2c4ec6ce71 100644
--- a/src/dbus/qdbuserror.h
+++ b/src/dbus/qdbuserror.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
struct DBusError;
QT_BEGIN_NAMESPACE
@@ -129,7 +127,5 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusError)
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h
index 0c68c79ac1..ba99d45c0d 100644
--- a/src/dbus/qdbusextratypes.h
+++ b/src/dbus/qdbusextratypes.h
@@ -51,8 +51,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -177,7 +175,5 @@ Q_DECLARE_METATYPE(QDBusVariant)
Q_DECLARE_METATYPE(QDBusObjectPath)
Q_DECLARE_METATYPE(QDBusSignature)
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 1cf9de5610..afb8506b28 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -244,7 +244,7 @@ static dbus_bool_t qDBusAddWatch(DBusWatch *watch, void *data)
QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data);
int flags = q_dbus_watch_get_flags(watch);
- int fd = q_dbus_watch_get_fd(watch);
+ int fd = q_dbus_watch_get_unix_fd(watch);
if (QCoreApplication::instance() && QThread::currentThread() == d->thread()) {
return qDBusRealAddWatch(d, watch, flags, fd);
@@ -295,7 +295,7 @@ static void qDBusRemoveWatch(DBusWatch *watch, void *data)
//qDebug("remove watch");
QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data);
- int fd = q_dbus_watch_get_fd(watch);
+ int fd = q_dbus_watch_get_unix_fd(watch);
QDBusWatchAndTimeoutLocker locker(RemoveWatchAction, d);
QDBusConnectionPrivate::WatcherHash::iterator i = d->watchers.find(fd);
@@ -326,7 +326,7 @@ static void qDBusToggleWatch(DBusWatch *watch, void *data)
Q_ASSERT(data);
QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data);
- int fd = q_dbus_watch_get_fd(watch);
+ int fd = q_dbus_watch_get_unix_fd(watch);
if (QCoreApplication::instance() && QThread::currentThread() == d->thread()) {
qDBusRealToggleWatch(d, watch, fd);
@@ -587,17 +587,76 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
return false;
}
+static void garbageCollectChildren(QDBusConnectionPrivate::ObjectTreeNode &node)
+{
+ int size = node.children.count();
+ if (node.activeChildren == 0) {
+ // easy case
+ node.children.clear();
+ } else if (size > node.activeChildren * 3 || (size > 20 && size * 2 > node.activeChildren * 3)) {
+ // rewrite the vector, keeping only the active children
+ // if the vector is large (> 20 items) and has one third of inactives
+ // or if the vector is small and has two thirds of inactives.
+ QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator end = node.children.end();
+ QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = node.children.begin();
+ QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator tgt = it;
+ for ( ; it != end; ++it) {
+ if (it->isActive())
+ *tgt++ = qMove(*it);
+ }
+ ++tgt;
+ node.children.erase(tgt, end);
+ }
+}
+
static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNode &haystack)
{
QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = haystack.children.begin();
QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator end = haystack.children.end();
- for ( ; it != end; ++it)
+ for ( ; it != end; ++it) {
+ if (!it->isActive())
+ continue;
huntAndDestroy(needle, *it);
+ if (!it->isActive())
+ --haystack.activeChildren;
+ }
if (needle == haystack.obj) {
haystack.obj = 0;
haystack.flags = 0;
}
+
+ garbageCollectChildren(haystack);
+}
+
+static void huntAndUnregister(const QStringList &pathComponents, int i, QDBusConnection::UnregisterMode mode,
+ QDBusConnectionPrivate::ObjectTreeNode *node)
+{
+ if (pathComponents.count() == i) {
+ // found it
+ node->obj = 0;
+ node->flags = 0;
+
+ if (mode == QDBusConnection::UnregisterTree) {
+ // clear the sub-tree as well
+ node->activeChildren = 0;
+ node->children.clear(); // can't disconnect the objects because we really don't know if they can
+ // be found somewhere else in the path too
+ }
+ } else {
+ // keep going
+ QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator end = node->children.end();
+ QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it =
+ std::lower_bound(node->children.begin(), end, pathComponents.at(i));
+ if (it == end || it->name != pathComponents.at(i) || !it->isActive())
+ return; // node not found
+
+ huntAndUnregister(pathComponents, i + 1, mode, it);
+ if (!it->isActive())
+ --node->activeChildren;
+
+ garbageCollectChildren(*node);
+ }
}
static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
@@ -606,8 +665,10 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
{
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = haystack.children.constBegin();
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end = haystack.children.constEnd();
- for ( ; it != end; ++it)
- huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + QLatin1Char('/') + it->name);
+ for ( ; it != end; ++it) {
+ if (it->isActive())
+ huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + QLatin1Char('/') + it->name);
+ }
if (needle == haystack.obj) {
// is this a signal we should relay?
@@ -1787,7 +1848,8 @@ void QDBusConnectionPrivate::waitForFinished(QDBusPendingCallPrivate *pcall)
}
}
-static inline bool waitingForFinishedIsSet(QDBusPendingCallPrivate *call)
+// this function is called only in a Q_ASSERT
+static inline Q_DECL_UNUSED bool waitingForFinishedIsSet(QDBusPendingCallPrivate *call)
{
const QMutexLocker locker(&call->mutex);
return call->waitingForFinished;
@@ -2249,6 +2311,21 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
}
}
+void QDBusConnectionPrivate::unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode)
+{
+ QDBusConnectionPrivate::ObjectTreeNode *node = &rootNode;
+ QStringList pathComponents;
+ int i;
+ if (path == QLatin1String("/")) {
+ i = 0;
+ } else {
+ pathComponents = path.split(QLatin1Char('/'));
+ i = 1;
+ }
+
+ huntAndUnregister(pathComponents, i, mode, node);
+}
+
void QDBusConnectionPrivate::connectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver,
@@ -2316,8 +2393,6 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service,
return;
}
}
-
- qWarning("QDBusConnectionPrivate::disconnectRelay called for a signal that was not found");
}
QString QDBusConnectionPrivate::getNameOwner(const QString& serviceName)
diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h
index fbaf04fff3..b44db0098f 100644
--- a/src/dbus/qdbusintegrator_p.h
+++ b/src/dbus/qdbusintegrator_p.h
@@ -116,7 +116,7 @@ public:
QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender,
const QDBusConnectionPrivate::ObjectTreeNode &n,
int p, const QDBusMessage &m, QSemaphore *s = 0)
- : QMetaCallEvent(0, -1, 0, sender, -1, 0, 0, 0, s), connection(c), node(n),
+ : QMetaCallEvent(0, ushort(-1), 0, sender, -1, 0, 0, 0, s), connection(c), node(n),
pathStartPos(p), message(m), handled(false)
{ }
~QDBusActivateObjectEvent();
diff --git a/src/dbus/qdbusinterface.h b/src/dbus/qdbusinterface.h
index 5750feb027..d2bb1da369 100644
--- a/src/dbus/qdbusinterface.h
+++ b/src/dbus/qdbusinterface.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -75,7 +73,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusintrospection_p.h b/src/dbus/qdbusintrospection_p.h
index a9f3773acc..b892ed95f1 100644
--- a/src/dbus/qdbusintrospection_p.h
+++ b/src/dbus/qdbusintrospection_p.h
@@ -97,7 +97,7 @@ public:
inline bool operator==(const Argument& other) const
{ return name == other.name && type == other.type; }
};
-
+
struct Method
{
QString name;
diff --git a/src/dbus/qdbusmacros.h b/src/dbus/qdbusmacros.h
index f2c0fafa8f..5a95f53261 100644
--- a/src/dbus/qdbusmacros.h
+++ b/src/dbus/qdbusmacros.h
@@ -57,7 +57,6 @@
#include <QtCore/qvector.h>
#endif
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DBUS
@@ -75,6 +74,5 @@ QT_BEGIN_NAMESPACE
#endif // QT_NO_DBUS
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h
index 72caf312ec..8f8954c1ce 100644
--- a/src/dbus/qdbusmessage.h
+++ b/src/dbus/qdbusmessage.h
@@ -53,8 +53,6 @@
# undef interface
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -130,8 +128,6 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusMessage)
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp
index f3bd7c28ba..799c66f6f9 100644
--- a/src/dbus/qdbusmetaobject.cpp
+++ b/src/dbus/qdbusmetaobject.cpp
@@ -77,7 +77,7 @@ private:
QVarLengthArray<int, 4> outputTypes;
int flags;
};
-
+
struct Property {
QByteArray typeName;
QByteArray signature;
@@ -92,14 +92,14 @@ private:
QMap<QByteArray, Method> signals_;
QMap<QByteArray, Method> methods;
QMap<QByteArray, Property> properties;
-
+
const QDBusIntrospection::Interface *data;
QString interface;
Type findType(const QByteArray &signature,
const QDBusIntrospection::Annotations &annotations,
const char *direction = "Out", int id = -1);
-
+
void parseMethods();
void parseSignals();
void parseProperties();
@@ -258,7 +258,7 @@ void QDBusMetaObjectGenerator::parseMethods()
mm.inputTypes.append(type.id);
mm.parameterNames.append(arg.name.toLatin1());
-
+
prototype.append(type.name);
prototype.append(',');
}
@@ -331,7 +331,7 @@ void QDBusMetaObjectGenerator::parseSignals()
mm.inputTypes.append(type.id);
mm.parameterNames.append(arg.name.toLatin1());
-
+
prototype.append(type.name);
prototype.append(',');
}
@@ -361,7 +361,7 @@ void QDBusMetaObjectGenerator::parseProperties()
Type type = findType(p.type.toLatin1(), p.annotations);
if (type.id == QVariant::Invalid)
continue;
-
+
QByteArray name = p.name.toLatin1();
mp.signature = p.type.toLatin1();
mp.type = type.id;
@@ -564,7 +564,7 @@ void QDBusMetaObjectGenerator::writeWithoutXml(const QString &interface)
char *stringdata = new char[name.length() + 1];
stringdata[name.length()] = '\0';
-
+
d.data = reinterpret_cast<uint*>(header);
d.relatedMetaObjects = 0;
d.static_metacall = 0;
@@ -615,7 +615,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
if (we)
return we;
// still nothing?
-
+
if (parsed.isEmpty()) {
// object didn't return introspection
we = new QDBusMetaObject;
@@ -627,7 +627,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
// merge all interfaces
it = parsed.constBegin();
QDBusIntrospection::Interface merged = *it.value().constData();
-
+
for (++it; it != end; ++it) {
merged.annotations.unite(it.value()->annotations);
merged.methods.unite(it.value()->methods);
diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp
index ff5818d684..804e80699a 100644
--- a/src/dbus/qdbusmetatype.cpp
+++ b/src/dbus/qdbusmetatype.cpp
@@ -318,10 +318,10 @@ int QDBusMetaType::signatureToType(const char *signature)
case DBUS_TYPE_UINT16:
return QMetaType::UShort;
-
+
case DBUS_TYPE_INT32:
return QVariant::Int;
-
+
case DBUS_TYPE_UINT32:
return QVariant::UInt;
@@ -375,7 +375,7 @@ int QDBusMetaType::signatureToType(const char *signature)
/*!
\fn QDBusMetaType::typeToSignature(int type)
- \internal
+ \internal
Returns the D-Bus signature equivalent to the supplied meta type id \a type.
diff --git a/src/dbus/qdbusmetatype.h b/src/dbus/qdbusmetatype.h
index af73902ee5..bc556a0157 100644
--- a/src/dbus/qdbusmetatype.h
+++ b/src/dbus/qdbusmetatype.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -93,7 +91,5 @@ int qDBusRegisterMetaType(
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h
index 9fa78f3702..19bc34c26b 100644
--- a/src/dbus/qdbuspendingcall.h
+++ b/src/dbus/qdbuspendingcall.h
@@ -51,8 +51,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -122,7 +120,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
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..b7e459f7a7 100644
--- a/src/dbus/qdbuspendingreply.h
+++ b/src/dbus/qdbuspendingreply.h
@@ -49,8 +49,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -107,6 +105,10 @@ namespace QDBusPendingReplyTypes {
static inline void fillMetaTypes(int *)
{ }
};
+
+ struct TypeIsVoid {};
+ template <typename T> struct NotVoid { typedef T Type; };
+ template <> struct NotVoid<void> { typedef TypeIsVoid Type; };
} // namespace QDBusPendingReplyTypes
template<typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
@@ -168,9 +170,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);
}
@@ -180,7 +180,7 @@ public:
return argumentAt<0>();
}
- inline operator typename Select<0>::Type() const
+ inline operator typename QDBusPendingReplyTypes::NotVoid<T1>::Type() const
{
return argumentAt<0>();
}
@@ -210,7 +210,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusreply.h b/src/dbus/qdbusreply.h
index 22242bc97d..4567c80131 100644
--- a/src/dbus/qdbusreply.h
+++ b/src/dbus/qdbusreply.h
@@ -53,8 +53,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -71,7 +69,7 @@ public:
}
inline QDBusReply& operator=(const QDBusMessage &reply)
{
- QVariant data(qMetaTypeId(&m_data), reinterpret_cast<void*>(0));
+ QVariant data(qMetaTypeId<Type>(), reinterpret_cast<void*>(0));
qDBusReplyFill(reply, m_error, data);
m_data = qvariant_cast<Type>(data);
return *this;
@@ -113,6 +111,7 @@ public:
inline bool isValid() const { return !m_error.isValid(); }
inline const QDBusError& error() { return m_error; }
+ inline const QDBusError& error() const { return m_error; }
inline Type value() const
{
@@ -184,6 +183,7 @@ public:
inline bool isValid() const { return !m_error.isValid(); }
inline const QDBusError& error() { return m_error; }
+ inline const QDBusError& error() const { return m_error; }
private:
QDBusError m_error;
@@ -192,7 +192,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusserver.h b/src/dbus/qdbusserver.h
index 0fbb96d206..d455f8e0ec 100644
--- a/src/dbus/qdbusserver.h
+++ b/src/dbus/qdbusserver.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -78,7 +76,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusservicewatcher.h b/src/dbus/qdbusservicewatcher.h
index 5f14b5e64c..0988d82550 100644
--- a/src/dbus/qdbusservicewatcher.h
+++ b/src/dbus/qdbusservicewatcher.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -99,7 +97,5 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusServiceWatcher::WatchMode)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif // QDBUSSERVICEWATCHER_H
diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h
index 74c2ba307e..5e8f60817f 100644
--- a/src/dbus/qdbusunixfiledescriptor.h
+++ b/src/dbus/qdbusunixfiledescriptor.h
@@ -52,8 +52,6 @@
# include <utility>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -97,7 +95,5 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusUnixFileDescriptor)
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif // QDBUSUNIXFILEDESCRIPTOR_H
diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h
index c77d8791df..5d8b3a1293 100644
--- a/src/dbus/qdbusutil_p.h
+++ b/src/dbus/qdbusutil_p.h
@@ -61,8 +61,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
namespace QDBusUtil
@@ -161,7 +159,5 @@ namespace QDBusUtil
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusvirtualobject.cpp b/src/dbus/qdbusvirtualobject.cpp
index 8f64d22643..d6d4f01a33 100644
--- a/src/dbus/qdbusvirtualobject.cpp
+++ b/src/dbus/qdbusvirtualobject.cpp
@@ -58,16 +58,14 @@ QT_END_NAMESPACE
/*!
- \internal
\class QDBusVirtualObject
\inmodule QtDBus
- \since 4.8
+ \since 5.1
\brief The QDBusVirtualObject class is used to handle several DBus paths with one class.
*/
/*!
- \internal
\fn bool QDBusVirtualObject::handleMessage(const QDBusMessage &message, const QDBusConnection &connection) = 0
This function needs to handle all messages to the path of the
@@ -78,7 +76,6 @@ QT_END_NAMESPACE
/*!
- \internal
\fn QString QDBusVirtualObject::introspect(const QString &path) const
This function needs to handle the introspection of the
diff --git a/src/dbus/qdbusvirtualobject.h b/src/dbus/qdbusvirtualobject.h
index ada800940d..da63082c70 100644
--- a/src/dbus/qdbusvirtualobject.h
+++ b/src/dbus/qdbusvirtualobject.h
@@ -48,8 +48,6 @@
#ifndef QT_NO_DBUS
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -74,7 +72,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_DBUS
#endif