fixed a bug where improper event removals could cause a crash

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401028
This commit is contained in:
David Anderson 2007-06-26 22:28:37 +00:00
parent 37622cece6
commit 1915dd049e

View File

@ -262,7 +262,16 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun
IPlugin *plugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext()); IPlugin *plugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
/* Get plugin's event hook list */ /* Get plugin's event hook list */
plugin->GetProperty("EventHooks", (void**)&pHookList); if (!plugin->GetProperty("EventHooks", (void**)&pHookList))
{
return EventHookErr_NotActive;
}
/* Make sure the event was actually being hooked */
if (pHookList->find(pHook) == pHookList->end())
{
return EventHookErr_NotActive;
}
/* Remove current structure from plugin's list */ /* Remove current structure from plugin's list */
pHookList->remove(pHook); pHookList->remove(pHook);