diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-06-19 12:57:19 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-06-24 14:38:07 +0200 |
| commit | c1924afcd8239b294bcb0380f573474b5eb16906 (patch) | |
| tree | fe0e0d3de77fb5b68de376b685c617ecfa586f54 /src/qml/jsapi/qjsengine.cpp | |
| parent | 9ba7a4cf7e161992209960c32c9fccb445dceec2 (diff) | |
QtQml: Move ExecutionEngine in to QJSEnginePrivate
The ExecutionEngine can live without a QQmlEngine or a QJSEngine, but
not vice versa. Therefore, the ExecutionEngine has to outlive QQmlEngine
and QJSEngine on shutdown.
Since the ExecutionEngine lives longer now, we also need to postpone the
pruning of the type registry. The engine might still hold on to types
after all.
Task-number: QTBUG-137848
Change-Id: Ib574cac84b5f2d974cbc24ed79550a58b69a7a1c
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qml/jsapi/qjsengine.cpp')
| -rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index b920647de5..e76d7b6507 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -357,8 +357,9 @@ QJSEngine::QJSEngine(QObject *parent) */ QJSEngine::QJSEngine(QJSEnginePrivate &dd, QObject *parent) : QObject(dd, parent) - , m_v4Engine(new QV4::ExecutionEngine(this)) { + dd.v4Engine = std::make_unique<QV4::ExecutionEngine>(this); + m_v4Engine = dd.v4Engine.get(); checkForApplicationInstance(); } @@ -373,7 +374,7 @@ QJSEngine::~QJSEngine() { m_v4Engine->inShutdown = true; QJSEnginePrivate::removeFromDebugServer(this); - delete m_v4Engine; + m_v4Engine->publicEngine = nullptr; } /*! @@ -1263,10 +1264,7 @@ QJSEnginePrivate *QJSEnginePrivate::get(QV4::ExecutionEngine *e) return e->jsEngine()->d_func(); } -QJSEnginePrivate::~QJSEnginePrivate() -{ - QQmlMetaType::freeUnusedTypesAndCaches(); -} +QJSEnginePrivate::~QJSEnginePrivate() = default; void QJSEnginePrivate::addToDebugServer(QJSEngine *q) { |
