Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.14.1
Description
We have an application that we want to make scriptable. To achieve this we use QQmlEngine or QJSEngine (they both behave the same way). To make scripting easier we want to return objects to script and be able to call object methods. We create a Q_INVOKABLE which returns a QObject-inherited wrapper over an actual object and we want this wrapper to be deleted after finisning script (an actual data is not deleted).
Returned object has JavaScript ownership by default (according to the documenatation and all tests I've done) and after we finish script and delete underlying engine, it is deleted properly.
But if we return QList <QObject *> the very same way, these objects are not deleted which causes a memory leak.
A minimal reproducable example is attached, you can also find it on github
https://github.com/BeardedBeaver/QmlPassObjectTest
To summarize - a single QObject pointer returned to QQmlEngine from C++ is deleted properly, while QList <QObject *> returned the very same way with the very same settings is not deleted which causes a memory leak.