qt/0009-This-patch-fixes-deserialization-of-values-with-cust.patch

55 lines
2.6 KiB
Diff
Raw Normal View History

From b274bbaf4768dcfdfcf95ceda08b6402ffedb80d Mon Sep 17 00:00:00 2001
From: George Goldberg <grundleborg@googlemail.com>
Date: Tue, 28 Apr 2009 17:08:07 +0200
Subject: [PATCH 09/18] This patch fixes deserialization of values with custom types when setting
properties on dbus adaptors. It is needed, in particular by telepathy/Qt
programs and libraries. The bug was reported to Nokia on 2009-01-07 along
with the patch supplied here. The summary of the issue from the Qt
Software task tracker follows:
When calling the setter for a DBus property, if that property has a custom type
(e.g. a struct with dbus type (uss)), QtDBus fails to demarshall the
QDBusArgument before attempting to set the property on the adaptor. The result
is that it attempts to call adaptor->setProperty() with a QDBusArgument of type
"uss" instead of with the type of the custom struct.
qt-bugs@ issue : N240326
Qt Software task ID : 240608
bugs.kde.org number : none
---
src/dbus/qdbusinternalfilters.cpp | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp
index c71f2f4..d261d01 100644
--- a/src/dbus/qdbusinternalfilters.cpp
+++ b/src/dbus/qdbusinternalfilters.cpp
@@ -274,9 +274,23 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
it = qLowerBound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
interface_name);
- if (it != connector->adaptors.end() && interface_name == QLatin1String(it->interface))
+ if (it != connector->adaptors.end() && interface_name == QLatin1String(it->interface)) {
+ if (value.userType() == qMetaTypeId<QDBusArgument>()) {
+ QDBusArgument valueArg = qvariant_cast<QDBusArgument>(value);
+ if (valueArg.currentType() != -1) {
+ int mid = it->adaptor->metaObject()->property(it->adaptor->metaObject()->indexOfProperty(property_name)).userType();
+ void *null = 0;
+ QVariant valueStore(mid, null);
+ QDBusMetaType::demarshall(valueArg, mid, valueStore.data());
+
+ if (it->adaptor->setProperty(property_name, valueStore))
+ return msg.createReply();
+ }
+ }
+
if (it->adaptor->setProperty(property_name, value))
return msg.createReply();
+ }
}
}
--
1.6.2.5