diff options
| author | Eike Ziller <eike.ziller@qt.io> | 2025-02-03 13:05:24 +0100 |
|---|---|---|
| committer | Eike Ziller <eike.ziller@qt.io> | 2025-02-03 13:05:24 +0100 |
| commit | 89c7a20f165736cedf0229d335a401fb57dc8eb4 (patch) | |
| tree | 841b3bf685ecad2e1d81000c375cd86e4586ee64 /src/plugins/lua/luaengine.cpp | |
| parent | 69f8c28dd9836f6f8ee87d745f8d66ad9ec5f61e (diff) | |
| parent | 2ad4ff803658033c800e409499bc10c99c96363c (diff) | |
Merge remote-tracking branch 'origin/15.0' into 16.0
Change-Id: I5b06931d91898e8548764238801d5c947fcfacf8
Diffstat (limited to 'src/plugins/lua/luaengine.cpp')
| -rw-r--r-- | src/plugins/lua/luaengine.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/lua/luaengine.cpp b/src/plugins/lua/luaengine.cpp index 5b6a24ab0fc..3975ef473ca 100644 --- a/src/plugins/lua/luaengine.cpp +++ b/src/plugins/lua/luaengine.cpp @@ -343,7 +343,12 @@ expected_str<sol::protected_function> prepareSetup( // TODO: only register what the plugin requested for (const auto &[name, func] : d->m_providers.asKeyValueRange()) { lua["package"]["preload"][name.toStdString()] = [func = func](const sol::this_state &s) { - return func(s); + sol::state_view lua = s; + // We need to make sure that providers work on the main_thread, otherwise they might + // crash when trying to access the lua state on destruction. + if (isCoroutine(lua)) + lua = sol::main_thread(lua); + return func(lua); }; } |
