Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.15.8, 6.4
-
6901eacff4 (qt/qtdeclarative/dev) 6901eacff4 (qt/tqtc-qtdeclarative/dev) a02496b639 (qt/qtdeclarative/6.3) ce8db06725 (qt/qtdeclarative/6.2) ce8db06725 (qt/tqtc-qtdeclarative/6.2) a02496b639 (qt/tqtc-qtdeclarative/6.3) ce8db06725 (qt/qtdeclarative/6.2.4)
Description
This model is registered as a QML singleton:
class SingletonModel : public QStringListModel { Q_OBJECT public: SingletonModel(QObject* parent) : QStringListModel(parent) { } }; // ... qmlRegisterSingletonType<SingletonModel>(uri, 1, 0, "SingletonModel", [](QQmlEngine* engine, QJSEngine*) -> QObject* { return new SingletonModel; });
If ListView is destroyed with that object as the model, the singleton breaks and will crash on next access:
Component { id: view ListView { model: SingletonModel } } function test_singletonModelCrash() { SingletonModel.objectName = "model" var o = view.createObject(root) // no crash: o.model = null o.destroy() compare(SingletonModel.objectName, "model") wait(1) // crash compare(SingletonModel.objectName, "model") }
QV4::QQmlTypeWrapper::virtualResolveLookupGetter (object=<optimized out>, engine=<optimized out>, lookup=<optimized out>) at qml/qqmltypewrapper.cpp:462 462 lookup->qobjectLookup.ic = val->objectValue()->internalClass();
The SingletonModel instance is not destroyed. Setting a QObject parent or CppOwnership prevents the bug, but from what I understand the code above is valid and the engine should have "ownership".
Attachments
Issue Links
- mentioned in
-
Page Loading...