From 29a160f4f039f48ed37ea88c749808fefb752afa Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 22 Jul 2015 13:21:23 +0000 Subject: MirLua: fixed script unloading git-svn-id: http://svn.miranda-ng.org/main/trunk@14630 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_script.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'plugins/MirLua/src/mlua_script.cpp') diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp index bbc3fd4355..7ac927deaf 100644 --- a/plugins/MirLua/src/mlua_script.cpp +++ b/plugins/MirLua/src/mlua_script.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" -CMLuaScript::CMLuaScript(lua_State *L, const TCHAR* path, int iGroup) : L(L) +CMLuaScript::CMLuaScript(lua_State *L, const TCHAR* path, int iGroup) + : L(L), unloadRef(0) { mir_tstrcpy(filePath, path); @@ -83,10 +84,10 @@ bool CMLuaScript::Load() void CMLuaScript::Unload() { - if (isLoaded) + if (isLoaded && unloadRef) { lua_rawgeti(L, LUA_REGISTRYINDEX, unloadRef); - if (lua_pcall(L, 0, 0, 0)) + if (lua_isfunction(L, -1) && lua_pcall(L, 0, 0, 0)) CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1)); luaL_unref(L, LUA_REGISTRYINDEX, unloadRef); isLoaded = false; -- cgit v1.2.3