From 72235a6530831a13c940839c53e873740fad71b7 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 5 Jul 2010 14:18:43 -0300 Subject: Use original name on QVariant type lookup function. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtCore/qvariant_conversions.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'PySide') diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index 076ed7f92..613e523d2 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -45,21 +45,14 @@ struct Converter return QVariant::fromValue(pyObj); } else { // a class supported by QVariant? - const char* typeName = pyObj->ob_type->tp_name; - // check if the name starts with PySide. - if (!strncmp("PySide.", typeName, 7)) { - // get the type name - const char* lastDot = typeName; - for (int i = 8; typeName[i]; ++i) { - if (typeName[i] == '.') - lastDot = &typeName[i]; - } - lastDot++; - uint typeCode = QMetaType::type(lastDot); + if (Shiboken::isShibokenType(pyObj)) { + Shiboken::SbkBaseWrapperType *objType = reinterpret_cast(pyObj->ob_type); + const char* typeName = objType->original_name; + uint typeCode = QMetaType::type(typeName); if (!typeCode) {// Try with star at end, for QObject*, QWidget* and QAbstractKinectScroller* - QString typeName(lastDot); - typeName += '*'; - typeCode = QMetaType::type(typeName.toAscii()); + QString stypeName(typeName); + stypeName += '*'; + typeCode = QMetaType::type(stypeName.toAscii()); } if (typeCode) return QVariant(typeCode, reinterpret_cast(pyObj)->cptr[0]); @@ -69,7 +62,11 @@ struct Converter } } - static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } + static PyObject* toPython(void* cppObj) + { + return toPython(*reinterpret_cast(cppObj)); + } + static PyObject* toPython(const QVariant& cppObj) { if (cppObj.isValid()) { -- cgit v1.2.3