Fix shutdown crash

This commit is contained in:
Rochet2
2015-03-12 18:54:06 +02:00
parent 9452beae3d
commit a2955a3081
3 changed files with 5 additions and 3 deletions

View File

@@ -108,7 +108,8 @@ void ElunaEventProcessor::AddEvent(int funcRef, uint32 delay, uint32 repeats)
void ElunaEventProcessor::RemoveEvent(LuaEvent* luaEvent)
{
if (luaEvent->state != LUAEVENT_STATE_ERASE && Eluna::IsInitialized())
// Unreference if should and if Eluna was not yet uninitialized and if the lua state still exists
if (luaEvent->state != LUAEVENT_STATE_ERASE && Eluna::IsInitialized() && (*E)->HasLuaState())
{
// Free lua function ref
luaL_unref((*E)->L, LUA_REGISTRYINDEX, luaEvent->funcRef);