summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PySide/QtCore/qvariant_conversions.h11
-rw-r--r--tests/QtCore/qobject_property_test.py8
2 files changed, 14 insertions, 5 deletions
diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h
index 3056bd9..b47e389 100644
--- a/PySide/QtCore/qvariant_conversions.h
+++ b/PySide/QtCore/qvariant_conversions.h
@@ -20,15 +20,16 @@ struct Converter<QVariant>
Shiboken::SbkBaseWrapperType *sbkType = reinterpret_cast<Shiboken::SbkBaseWrapperType*>(type);
const char* typeName = sbkType->original_name;
- // Do not resolve types to value type
- if (!QByteArray(typeName).endsWith("*"))
- return QByteArray();
-
int obTypeId = QMetaType::type(typeName);
if (obTypeId) {
typeId = obTypeId;
return QByteArray(typeName);
}
+
+ // Do not resolve types to value type
+ if (!QByteArray(typeName).endsWith("*"))
+ return QByteArray();
+
// find in base types
if (type->tp_base) {
return resolveMetaType(type->tp_base, typeId);
@@ -80,7 +81,7 @@ struct Converter<QVariant>
return convertToVariantList(pyObj);
} else {
// a class supported by QVariant?
- if (Shiboken::isShibokenType(pyObj)) {
+ if (Shiboken::isShibokenType(pyObj) && !Shiboken::isUserType(pyObj)) {
Shiboken::SbkBaseWrapperType *objType = reinterpret_cast<Shiboken::SbkBaseWrapperType*>(pyObj->ob_type);
int typeCode = 0;
QByteArray typeName = resolveMetaType(reinterpret_cast<PyTypeObject*>(objType), typeCode);
diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py
index 776a14d..adb1679 100644
--- a/tests/QtCore/qobject_property_test.py
+++ b/tests/QtCore/qobject_property_test.py
@@ -129,6 +129,14 @@ class PropertyCase(unittest.TestCase):
self.assertTrue(obj.property('foo') is mysize)
+ def testValueType(self):
+ rect = QRect(1, 2, 3, 4)
+ obj = QObject()
+ obj.setProperty('rect', rect)
+ '''Value types when converted to QVariant is copyed'''
+ self.assertFalse(obj.property('rect') is rect)
+ self.assertEqual(obj.property('rect'), rect)
+
class PropertyWithConstructorCase(unittest.TestCase):
'''Test case for QObject properties set using named arguments in the constructor.'''