Lua: Don't destroy lua state too early

The Lua state needs to stay alive as long as any references to it
may be alive. Therefore this patch leaves the destruction to the end.

Fixes: QTCREATORBUG-31087
Change-Id: Ic49723575f7d2fe474cba9546845b65d57d7dcd0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-06-19 18:53:39 +02:00
parent 8404bb5c81
commit 611f6bdbea
2 changed files with 3 additions and 6 deletions

View File

@@ -51,7 +51,7 @@ protected:
public: public:
using PackageProvider = std::function<sol::object(sol::state_view)>; using PackageProvider = std::function<sol::object(sol::state_view)>;
~LuaEngine(); ~LuaEngine() override;
static LuaEngine &instance(); static LuaEngine &instance();
Utils::expected_str<LuaPluginSpec *> loadPlugin(const Utils::FilePath &path); Utils::expected_str<LuaPluginSpec *> loadPlugin(const Utils::FilePath &path);

View File

@@ -144,14 +144,11 @@ bool LuaPluginSpec::delayedInitialize()
} }
ExtensionSystem::IPlugin::ShutdownFlag LuaPluginSpec::stop() ExtensionSystem::IPlugin::ShutdownFlag LuaPluginSpec::stop()
{ {
d->activeLuaState.reset(); d->activeLuaState->stack_clear();
return ExtensionSystem::IPlugin::ShutdownFlag::SynchronousShutdown; return ExtensionSystem::IPlugin::ShutdownFlag::SynchronousShutdown;
} }
void LuaPluginSpec::kill() void LuaPluginSpec::kill() {}
{
d->activeLuaState.reset();
}
bool LuaPluginSpec::printToOutputPane() const bool LuaPluginSpec::printToOutputPane() const
{ {