Lua: Bind lifetime of LuaEngine

We want to make sure that the LuaEngine is deleted when the plugin
is removed.

We also derive LuaEngine from QObject so we can use it as a guard in
QObject::connect calls.

Change-Id: I6b0568f11bee283f880ede9432b2a9fe83014758
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-05-02 14:33:21 +02:00
parent a13aa8d3de
commit 218f07bdef
4 changed files with 29 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "luaengine.h"
#include "luapluginloader.h"
#include <coreplugin/coreconstants.h>
@@ -34,8 +35,13 @@ class LuaPlugin : public ExtensionSystem::IPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Lua.json")
private:
std::unique_ptr<LuaEngine> m_luaEngine;
public:
LuaPlugin() = default;
LuaPlugin()
: m_luaEngine(new LuaEngine())
{}
~LuaPlugin() override = default;
void initialize() final