Fix crash when a method exposed to Kross returns QVariant with non-relocatable data

Review Request #128205 - Created June 16, 2016 and submitted

Information
Alexander Potashev
kross
master
Reviewers
kdeframeworks
kossebau
In the Python2 interpreter plugin we constuct a QVariant from a typeId
and a pointer to the data. When a method returns e.g. a QVariantMap
in a QVariant, the typeId is QVariant::Map, but toVoidStar() used to
point to the memory where the wrapper QVariant was stored, but the QMap
is actually stored elsewhere, because QTypeInfo<QVariantMap>::isStatic
is true.

It wasn't crashing with Qt4 because in Qt4 QVariantMap was stored in the
QVariant's internal store (the C++ union).

We add template specialization MetaTypeVariant<QVariant> to handle
QVariants differently: now we directly return QVariant::data().

This method does not crash anymore when called from a Python2 script:

QVariant returnEmptyMap()
{
    return QVariantMap();
}
Albert Astals Cid
Albert Astals Cid
Alexander Potashev
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 3a79f2acd114c1964b73e8914d659982115e4a2c by Alexander Potashev to branch master.
Loading...