Investigating a crash I found out that a non-QObject
derived registered meta type always passes if (obj)
checks even if it contains a nullptr
.
Outputting the return value says QVariant(Base*)
rather than null
.
I suspect that QVariant::isNull()
might be useful here:
Returns true if this is a null variant, false otherwise. A variant is considered null if it contains a default constructed value or a built-in type instance that has an isNull method, in which case the result would be the same as calling isNull on the wrapped object.
I assume that a nullptr
should qualify for a "default constructed value" here, but it doesn't seem to be picked up by conditional statements in QML.
So maybe it is possible to implement that check via a free function? Or maybe I am looking at a bug here?
Update: It was deemed a critical bug.