From 6fc1e0fc36f0732e79375a0e105816eb17893962 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Wed, 14 Oct 2015 14:18:58 +0300 Subject: Don't delete singletons objects owned by C++. This way we can enable the usage of a single singletons in both worlds. Currently singletons are destructed before the other QML types, and using a singleton that is owned by C++ we don't need to care about the destruction order anymore. Change-Id: I120fcb8659e16321ae6e70c7b0d62be3bc650d73 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlmetatype.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlmetatype.cpp') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 26271e3f03..1a27a487bd 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -242,7 +242,12 @@ void QQmlType::SingletonInstanceInfo::destroy(QQmlEngine *e) // cleans up the engine-specific singleton instances if they exist. scriptApis.remove(e); QObject *o = qobjectApis.take(e); - delete o; + if (o) { + QQmlData *ddata = QQmlData::get(o, false); + if (ddata && ddata->indestructible) + return; + delete o; + } } void QQmlType::SingletonInstanceInfo::setQObjectApi(QQmlEngine *e, QObject *o) -- cgit v1.2.3