summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2019-02-08 12:05:19 +0100
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2019-02-08 15:28:52 +0000
commit1e5643d42eb7165aa6097bd5ccfcb4eb5e1477ac (patch)
tree07e7b7ffa92b58cd065a22a207be92821003f1f2
parentb2a09c05e9cc2503f1609f720060558c0db2fe03 (diff)
Return PyObject wrapper when not valid QVariant
When resolving the meta type of QVariant we did not have a fallback case. So we had a NoneType when none of the converters worked. These changes allow to return a PyObjectWrapper of the object instead of NoneType. This allow users to use any type as QVariant. Change-Id: I18da3f10f6839975fdc0bf2ac62f6bd7063312df Fixes: PYSIDE-45 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index ca88b974..62948445 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -1618,12 +1618,16 @@ double in = %CONVERTTOCPP[double](%in);
// a class supported by QVariant?
int typeCode;
const char *typeName = QVariant_resolveMetaType(Py_TYPE(%in), &typeCode);
-if (!typeCode || !typeName)
- return;
-QVariant var(typeCode, (void*)0);
-Shiboken::Conversions::SpecificConverter converter(typeName);
-converter.toCpp(pyIn, var.data());
-%out = var;
+if (!typeCode || !typeName) {
+ // If the type was not encountered, return a default PyObjectWrapper
+ %out = QVariant::fromValue(PySide::PyObjectWrapper(%in));
+}
+else {
+ QVariant var(typeCode, (void*)0);
+ Shiboken::Conversions::SpecificConverter converter(typeName);
+ converter.toCpp(pyIn, var.data());
+ %out = var;
+}
// @snippet conversion-sbkobject
// @snippet conversion-pydict