summaryrefslogtreecommitdiff
path: root/plugins/MirLua
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-07-22 13:21:23 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-07-22 13:21:23 +0000
commit29a160f4f039f48ed37ea88c749808fefb752afa (patch)
tree53468a9792f7d747d49050f8f2a9b07fb5b22fac /plugins/MirLua
parentea7ac371c2f11dcb1b4fa230b6a6eff75768b001 (diff)
MirLua: fixed script unloading
git-svn-id: http://svn.miranda-ng.org/main/trunk@14630 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r--plugins/MirLua/src/mlua_script.cpp7
1 files changed, 4 insertions, 3 deletions
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;