diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-09-16 13:49:26 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-09-16 14:52:40 +0200 |
commit | 8c6755aeec312ae771ef334fc863642514db3f7c (patch) | |
tree | 3ccec405ee35690bdb7def6c0a3c42866bd9adc2 /src/dbus | |
parent | 104debb6627d71f5540bb2c3347ce56dddc63594 (diff) | |
parent | c40a48af997f57caa0ecfca0b247837ba5b2f89b (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/corelib/tools/qstring.cpp
Change-Id: Ifc6cd3a0f1cf14cc0fe6cf30afb0c7f40cfdbc3e
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusabstractadaptor_p.h | 4 | ||||
-rw-r--r-- | src/dbus/qdbusconnection.cpp | 3 | ||||
-rw-r--r-- | src/dbus/qdbusconnection_p.h | 15 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 41 |
4 files changed, 23 insertions, 40 deletions
diff --git a/src/dbus/qdbusabstractadaptor_p.h b/src/dbus/qdbusabstractadaptor_p.h index 3dc8cd320e..284b0fb706 100644 --- a/src/dbus/qdbusabstractadaptor_p.h +++ b/src/dbus/qdbusabstractadaptor_p.h @@ -104,6 +104,10 @@ public: // typedefs { return QLatin1String(interface) < other; } inline bool operator<(const QByteArray &other) const { return interface < other; } +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 + friend inline bool operator<(const QString &str, const AdaptorData &obj) + { return str < QLatin1String(obj.interface); } +#endif }; typedef QVector<AdaptorData> AdaptorMap; diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index a29ba4cb0f..320787c265 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -804,7 +804,7 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis return false; if (options & QDBusConnectionPrivate::VirtualObject) { - if (options & SubPath && node->activeChildren) + if (options & SubPath && !node->children.isEmpty()) return false; } else { if ((options & ExportChildObjects && !node->children.isEmpty())) @@ -842,7 +842,6 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis } } else { // add entry - ++node->activeChildren; node = node->children.insert(it, pathComponents.at(i)); } diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 013896bd32..515eab6dfe 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -140,16 +140,24 @@ public: { typedef QVector<ObjectTreeNode> DataList; - inline ObjectTreeNode() : obj(0), flags(0), activeChildren(0) { } + inline ObjectTreeNode() : obj(0), flags(0) { } inline ObjectTreeNode(const QString &n) // intentionally implicit - : name(n), obj(0), flags(0), activeChildren(0) { } + : name(n), obj(0), flags(0) { } inline ~ObjectTreeNode() { } inline bool operator<(const QString &other) const { return name < other; } inline bool operator<(const QStringRef &other) const { return QStringRef(&name) < other; } +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 + inline bool operator<(const ObjectTreeNode &other) const + { return name < other.name; } + friend inline bool operator<(const QString &str, const ObjectTreeNode &obj) + { return str < obj.name; } + friend inline bool operator<(const QStringRef &str, const ObjectTreeNode &obj) + { return str < QStringRef(&obj.name); } +#endif inline bool isActive() const - { return obj || activeChildren; } + { return obj || !children.isEmpty(); } QString name; union { @@ -157,7 +165,6 @@ public: QDBusVirtualObject *treeNode; }; int flags; - int activeChildren; DataList children; }; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index e5f3fbdc53..d797fbfb99 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -587,46 +587,22 @@ 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) { - if (!it->isActive()) - continue; + + while (it != haystack.children.end()) { huntAndDestroy(needle, *it); if (!it->isActive()) - --haystack.activeChildren; + it = haystack.children.erase(it); + else + it++; } if (needle == haystack.obj) { haystack.obj = 0; haystack.flags = 0; } - - garbageCollectChildren(haystack); } static void huntAndUnregister(const QStringList &pathComponents, int i, QDBusConnection::UnregisterMode mode, @@ -639,7 +615,6 @@ static void huntAndUnregister(const QStringList &pathComponents, int i, QDBusCon 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 } @@ -648,14 +623,12 @@ static void huntAndUnregister(const QStringList &pathComponents, int i, QDBusCon 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()) + if (it == end || it->name != pathComponents.at(i)) return; // node not found huntAndUnregister(pathComponents, i + 1, mode, it); if (!it->isActive()) - --node->activeChildren; - - garbageCollectChildren(*node); + node->children.erase(it); } } |