summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_options.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-06-16 08:03:15 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-06-16 08:03:15 +0000
commit379d05e49fd38452c8071ff4069bd8d54b6e7b01 (patch)
tree19fb2622327a5255222df076447ff1486ab3f650 /plugins/MirLua/src/m_options.cpp
parentc990f4c72d79cc5b70d7c27d2acfce906e5f6100 (diff)
MirLua: fixed m_options module
git-svn-id: http://svn.miranda-ng.org/main/trunk@16990 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_options.cpp')
-rw-r--r--plugins/MirLua/src/m_options.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/plugins/MirLua/src/m_options.cpp b/plugins/MirLua/src/m_options.cpp
index f41d4b6006..fb74776ca8 100644
--- a/plugins/MirLua/src/m_options.cpp
+++ b/plugins/MirLua/src/m_options.cpp
@@ -3,13 +3,13 @@
class CMLuaScriptOptionPage : public CDlgBase
{
private:
- CMLuaScript *script;
+ lua_State *L;
int onInitDialogRef;
int onApplyRef;
public:
- CMLuaScriptOptionPage(CMLuaScript *script, int onInitDialogRef, int onApplyRef)
- : CDlgBase(g_hInstance, IDD_SCRIPTOPTIONSPAGE), script(script),
+ CMLuaScriptOptionPage(lua_State *L, int onInitDialogRef, int onApplyRef)
+ : CDlgBase(g_hInstance, IDD_SCRIPTOPTIONSPAGE), L(L),
onInitDialogRef(onInitDialogRef), onApplyRef(onApplyRef)
{
}
@@ -19,10 +19,10 @@ protected:
{
if (onInitDialogRef)
{
- lua_rawgeti(script->L, LUA_REGISTRYINDEX, onInitDialogRef);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, onInitDialogRef);
- lua_pushlightuserdata(script->L, (void*)this->GetHwnd());
- luaM_pcall(script->L, 1, 0);
+ lua_pushlightuserdata(L, (void*)this->GetHwnd());
+ luaM_pcall(L, 1, 0);
}
}
@@ -30,20 +30,24 @@ protected:
{
if (onApplyRef)
{
- lua_rawgeti(script->L, LUA_REGISTRYINDEX, onApplyRef);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, onApplyRef);
- lua_pushlightuserdata(script->L, (void*)this->GetHwnd());
- luaM_pcall(script->L, 1, 0);
+ lua_pushlightuserdata(L, (void*)this->GetHwnd());
+ luaM_pcall(L, 1, 0);
}
}
+
+ void OnDestroy()
+ {
+ lua_pushnil(L);
+ lua_rawsetp(L, LUA_REGISTRYINDEX, this);
+ }
};
void MakeOptionDialogPage(lua_State *L, OPTIONSDIALOGPAGE &odp)
{
- CMLuaScript *script = CMLuaScript::GetScriptFromEnviroment(L);
-
odp.hInstance = g_hInstance;
- odp.hLangpack = script->GetId();
+ odp.hLangpack = CMLuaScript::GetScriptIdFromEnviroment(L);
lua_getfield(L, -1, "Flags");
odp.flags = luaL_optinteger(L, -1, ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE);
@@ -77,8 +81,10 @@ void MakeOptionDialogPage(lua_State *L, OPTIONSDIALOGPAGE &odp)
onApplyRef = luaL_ref(L, LUA_REGISTRYINDEX);
else
lua_pop(L, 1);
-
- odp.pDialog = new CMLuaScriptOptionPage(script, onInitDialogRef, onApplyRef);
+
+ lua_State *T = lua_newthread(L);
+ lua_rawsetp(L, LUA_REGISTRYINDEX, T);
+ odp.pDialog = new CMLuaScriptOptionPage(T, onInitDialogRef, onApplyRef);
}
int opt_AddPage(lua_State *L)