From 0f45d1fbe20adbc022bcab6e0f76031f35a2e81d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 20 Mar 2015 16:51:49 +0100 Subject: cPluginLua:cResettable no longer shares CS with plugin. This fixes locking the resettable while the plugin is already gone. Hopefully no deadlocks. --- src/Bindings/PluginLua.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Bindings/PluginLua.cpp') diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index d133c091a..0a2a8411d 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -63,12 +63,17 @@ void cPluginLua::Close(void) return; } - // Notify and remove all m_Resettables: - for (auto resettable: m_Resettables) + // Notify and remove all m_Resettables (unlock the m_CriticalSection while resetting them): + cResettablePtrs resettables; + std::swap(m_Resettables, resettables); { - resettable->Reset(); - } - m_Resettables.clear(); + cCSUnlock Unlock(Lock); + for (auto resettable: resettables) + { + resettable->Reset(); + } + m_Resettables.clear(); + } // cCSUnlock (m_CriticalSection) // Release all the references in the hook map: for (cHookMap::iterator itrH = m_HookMap.begin(), endH = m_HookMap.end(); itrH != endH; ++itrH) @@ -1853,8 +1858,7 @@ void cPluginLua::CallbackWindowSlotChanged(int a_FnRef, cWindow & a_Window, int // cPluginLua::cResettable: cPluginLua::cResettable::cResettable(cPluginLua & a_Plugin): - m_Plugin(&a_Plugin), - m_CSPlugin(a_Plugin.m_CriticalSection) + m_Plugin(&a_Plugin) { } -- cgit v1.2.3