From 241b414aa6b8f080363055ec233eb421135bb7d6 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Tue, 21 Jun 2022 20:56:19 +0200 Subject: [PATCH] Correctly terminate LuaWorker if the game is being terminated due to an unhanded exception. --- apps/openmw/engine.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4234662d31..cac6be3658 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -912,6 +912,15 @@ public: mThread = std::thread([this]{ threadBody(); }); }; + ~LuaWorker() + { + if (mThread && mThread->joinable()) + { + Log(Debug::Error) << "Unexpected destruction of LuaWorker; likely there is an unhandled exception in the main thread."; + join(); + } + } + void allowUpdate() { if (!mThread)