Qt 5.2 property assert failure with interfaces



  • I have Qt 5.1.1 and Qt 5.2 on my machine and 5.2 is causing an assert failure in QQmlMetaObject::canConvert whereas 5.1.1 works fine. I've tracked it down to an instance where I'm assigning a derived class to a property that takes the interface class. I do have a work around which is to pass in QObject and use qobject_cast.

    Onto the code. Qml is straightforward:
    @FreeCameraControl {
    ...
    renderer: parent.renderer // renderer takes type Gui::Renderer (interface) and the instance is Viewer::ViewRender (derives from Gui::Renderer)
    }@

    Property causing the issue is in FreeCameraControl:
    @namespace Gui {
    FreeCameraControl {
    Q_PROPERTY(Renderer *renderer READ renderer WRITE setRenderer) // Not sure if this should be Gui::Renderer or just Renderer as it is now. Renderer works in 5.1.1 though
    }}@

    Class Gui::Renderer did have Q_DECLARE_INTERFACE(Gui::Renderer, "net.shadowpsi.engine.Renderer") and
    Viewer::ViewRender had Q_INTERFACES(Gui::Renderer) but I've since discovered it makes no difference if I remove these in 5.1.1.

    In QQmlPropertyPrivate::write the code goes into the property.isQObject branch. In here it calls this line
    QQmlMetaObject propMo = rawMetaObjectForType(enginePriv, propertyType);
    and propMo.isNull() ends up being true causing the assert to fail.

    Just for reference I do have another section where I'm using derived classes from a non abstract class and this works fine which is why I'm leaning towards the problem being the interface or interface with namespace.



  • I guess it's a bug. Please report in https://bugreports.qt-project.org/




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.