Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.2.0 Alpha
-
None
-
Linux 3.8.0-31-generic #46-Ubuntu SMP Tue Sep 10 20:03:44 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Description
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.