summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-03-04 17:25:58 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-03-04 17:25:58 +0000
commitccf3bef719e71ccafe3a0bd154d0e85d7184a15b (patch)
tree929deb7f48d9a33a3d384362aa02f5adf11d337f /plugins/MirLua/src
parent0d9b1a103e8fcec518b7ec6f9ba3f9591dc7b612 (diff)
MirLua: fixed crash on script reloading
git-svn-id: http://svn.miranda-ng.org/main/trunk@16424 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src')
-rw-r--r--plugins/MirLua/src/mlua.cpp12
-rw-r--r--plugins/MirLua/src/mlua_script.cpp24
-rw-r--r--plugins/MirLua/src/stdafx.h2
3 files changed, 22 insertions, 16 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp
index da56eeb902..9aab05a3a6 100644
--- a/plugins/MirLua/src/mlua.cpp
+++ b/plugins/MirLua/src/mlua.cpp
@@ -1,5 +1,7 @@
#include "stdafx.h"
+int hMLuaLangpack;
+
LIST<void> CMLua::HookRefs(1, HandleKeySortT);
LIST<void> CMLua::ServiceRefs(1, HandleKeySortT);
@@ -10,6 +12,8 @@ static int CompareScripts(const CMLuaScript* p1, const CMLuaScript* p2)
CMLua::CMLua() : L(NULL), Scripts(10, CompareScripts)
{
+ MUUID muidLast = MIID_LAST;
+ hMLuaLangpack = GetPluginLangId(muidLast, 0);
}
CMLua::~CMLua()
@@ -70,10 +74,10 @@ void CMLua::Unload()
KillModuleScheduleTasks();
KillModuleTTBButton();
- KillModuleIcons(hLangpack);
- KillModuleSounds(hLangpack);
- KillModuleMenus(hLangpack);
- KillModuleHotkeys(hLangpack);
+ KillModuleIcons(hMLuaLangpack);
+ KillModuleSounds(hMLuaLangpack);
+ KillModuleMenus(hMLuaLangpack);
+ KillModuleHotkeys(hMLuaLangpack);
KillObjectEventHooks(L);
KillObjectServices(L);
diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp
index 39b7bbf9e0..9a0d840c0c 100644
--- a/plugins/MirLua/src/mlua_script.cpp
+++ b/plugins/MirLua/src/mlua_script.cpp
@@ -28,18 +28,18 @@ CMLuaScript::~CMLuaScript()
bool CMLuaScript::GetScriptEnviroment(lua_State *L)
{
- lua_Debug ar;
- if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "f", &ar) == 0 || lua_iscfunction(L, -1))
- {
- lua_pop(L, 1);
+ lua_Debug ar;
+ if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "f", &ar) == 0 || lua_iscfunction(L, -1))
+ {
+ lua_pop(L, 1);
return false;
}
- const char *env = lua_getupvalue(L, -1, 1);
- if (!env || mir_strcmp(env, "_ENV") != 0)
- {
- lua_pop(L, 1);
- return false;
+ const char *env = lua_getupvalue(L, -1, 1);
+ if (!env || mir_strcmp(env, "_ENV") != 0)
+ {
+ lua_pop(L, 1);
+ return false;
}
return true;
@@ -47,8 +47,8 @@ bool CMLuaScript::GetScriptEnviroment(lua_State *L)
CMLuaScript* CMLuaScript::GetScriptFromEnviroment(lua_State *L)
{
- if (!GetScriptEnviroment(L))
- return NULL;
+ if (!GetScriptEnviroment(L))
+ return NULL;
lua_getfield(L, -1, SCRIPT);
CMLuaScript *script = (CMLuaScript*)lua_touserdata(L, -1);
@@ -63,7 +63,7 @@ int CMLuaScript::GetScriptIdFromEnviroment(lua_State *L)
if (script != NULL)
return script->id;
- return hLangpack;
+ return hMLuaLangpack;
}
const char* CMLuaScript::GetModuleName() const
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h
index 58cfb263ed..a6c84dd1e8 100644
--- a/plugins/MirLua/src/stdafx.h
+++ b/plugins/MirLua/src/stdafx.h
@@ -53,6 +53,8 @@ extern HINSTANCE g_hInstance;
extern CMLua *g_mLua;
+extern int hMLuaLangpack;
+
extern HANDLE g_hCLibsFolder;
extern HANDLE g_hScriptsFolder;
#ifdef _UNICODE