Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt 5.2 property assert failure with interfaces

    QML and Qt Quick
    2
    3
    913
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Babalas last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • D
        dasun last edited by

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

        1 Reply Last reply Reply Quote 0
        • B
          Babalas last edited by

          Ok "QTBUG-33950":https://bugreports.qt-project.org/browse/QTBUG-33950

          1 Reply Last reply Reply Quote 0
          • First post
            Last post