From 176d97969e494986bd0817a75fc3aa9b766b7357 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Fri, 4 Jul 2014 02:03:57 +0200 Subject: [PATCH] CLuaInstance::SignalBoxNew: Add 'parent' parameter... ...for the integration of signalbox in a parent cwindow --- src/gui/luainstance.cpp | 6 +++++- src/gui/luainstance.h | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 327b1c8a8..3d4a29788 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1636,15 +1636,19 @@ int CLuaInstance::SignalBoxNew(lua_State *L) std::string name, icon = std::string(NEUTRINO_ICON_INFO); int x = 110, y = 150, dx = 430, dy = 150; int vertical = true; + CLuaCWindow* parent = NULL; tableLookup(L, "x", x); tableLookup(L, "y", y); tableLookup(L, "dx", dx); tableLookup(L, "dy", dy); tableLookup(L, "vertical", vertical); + tableLookup(L, "parent", (void**)&parent); + CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL; CLuaSignalBox **udata = (CLuaSignalBox **) lua_newuserdata(L, sizeof(CLuaSignalBox *)); *udata = new CLuaSignalBox(); - (*udata)->s = new CSignalBox(x, y, dx, dy, NULL, (vertical!=0)?true:false); + (*udata)->s = new CSignalBox(x, y, dx, dy, NULL, (vertical!=0)?true:false, pw); + (*udata)->parent = pw; luaL_getmetatable(L, "signalbox"); lua_setmetatable(L, -2); return 1; diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index bda26c6aa..f69a42ae9 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -131,8 +131,9 @@ class CLuaSignalBox { public: CSignalBox *s; - CLuaSignalBox() { s = NULL; } - ~CLuaSignalBox() { delete s; } + CComponentsForm *parent; + CLuaSignalBox() { s = NULL; parent = NULL;} + ~CLuaSignalBox() { if (parent == NULL) delete s; } }; class CLuaComponentsText