Use original name on QVariant type lookup function.
Reviewer: Hugo Parente Lima <hugo.lima@openbossa.org>,
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
bc4aa5ca94
commit
72235a6530
1 changed files with 12 additions and 15 deletions
|
|
@ -45,21 +45,14 @@ struct Converter<QVariant>
|
||||||
return QVariant::fromValue<PySide::PyObjectWrapper>(pyObj);
|
return QVariant::fromValue<PySide::PyObjectWrapper>(pyObj);
|
||||||
} else {
|
} else {
|
||||||
// a class supported by QVariant?
|
// a class supported by QVariant?
|
||||||
const char* typeName = pyObj->ob_type->tp_name;
|
if (Shiboken::isShibokenType(pyObj)) {
|
||||||
// check if the name starts with PySide.
|
Shiboken::SbkBaseWrapperType *objType = reinterpret_cast<Shiboken::SbkBaseWrapperType*>(pyObj->ob_type);
|
||||||
if (!strncmp("PySide.", typeName, 7)) {
|
const char* typeName = objType->original_name;
|
||||||
// get the type name
|
uint typeCode = QMetaType::type(typeName);
|
||||||
const char* lastDot = typeName;
|
|
||||||
for (int i = 8; typeName[i]; ++i) {
|
|
||||||
if (typeName[i] == '.')
|
|
||||||
lastDot = &typeName[i];
|
|
||||||
}
|
|
||||||
lastDot++;
|
|
||||||
uint typeCode = QMetaType::type(lastDot);
|
|
||||||
if (!typeCode) {// Try with star at end, for QObject*, QWidget* and QAbstractKinectScroller*
|
if (!typeCode) {// Try with star at end, for QObject*, QWidget* and QAbstractKinectScroller*
|
||||||
QString typeName(lastDot);
|
QString stypeName(typeName);
|
||||||
typeName += '*';
|
stypeName += '*';
|
||||||
typeCode = QMetaType::type(typeName.toAscii());
|
typeCode = QMetaType::type(stypeName.toAscii());
|
||||||
}
|
}
|
||||||
if (typeCode)
|
if (typeCode)
|
||||||
return QVariant(typeCode, reinterpret_cast<SbkBaseWrapper*>(pyObj)->cptr[0]);
|
return QVariant(typeCode, reinterpret_cast<SbkBaseWrapper*>(pyObj)->cptr[0]);
|
||||||
|
|
@ -69,7 +62,11 @@ struct Converter<QVariant>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QVariant*>(cppObj)); }
|
static PyObject* toPython(void* cppObj)
|
||||||
|
{
|
||||||
|
return toPython(*reinterpret_cast<QVariant*>(cppObj));
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject* toPython(const QVariant& cppObj)
|
static PyObject* toPython(const QVariant& cppObj)
|
||||||
{
|
{
|
||||||
if (cppObj.isValid()) {
|
if (cppObj.isValid()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue