Detaching Q_Property before QML Component has been destroying.
-
I got the
Qmlproperty which value is base on value passed from backend via readingQ_Property:property bool isFullScreen: System.FullscreenEverythis worked fine, until I was needed to upgrade project to
5.14.2. Now when I'm closing application I got error:qrc:/qml/main.qml:13: TypeError: Cannot read property 'Fullscreen' of nullNo I'm trying to figure out how can if thats happen. I was trying to use
Component.onDestruction, but it is emited after backend has been detached from qml front.Also I was trying this:
property bool isFullScreen: { if (Component.status === Component.Ready) return System.Fullscreen else return false }But the Component is binding only to
falseAny idea?
-
Your backend gets destroyed before QML does. The solution is usually to rearrange how you initialise things in your
main.cpp. Make sure backend outlives the engine and you won't see these errors (btw. they are completely harmless). -
Hi @sierdzio I was thinking about it but not sure how to do that.
Currently I just have the Connection between QApplication signal and my backend slot to clean befor quiting the App.
I was trying to add
QObject::connect(&app, &QApplication::aboutToQuit, [&engine, &system] { engine.quit(); system.disconnect(); )};But it doesn't change anything. I guess there should be a method to stop engine but can't find in docs https://doc.qt.io/qt-5/qqmlapplicationengine.html
Am I doing something wrong or maybe you know how the enginge should be stopped?
-
You can parent your QObjects to QML engine and Qt will clean it up for you.
QQmlEngine engine; So something like: auto system = new System(&engine); engine.rootContext()->setContextProperty("System", system); -
Yeah, but where is that
integratorcreated? What manages it's lifetime?