diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/lua.cc | 18 | ||||
-rw-r--r-- | client/lua.h | 2 | ||||
-rw-r--r-- | client/macrowindow.cc | 22 | ||||
-rw-r--r-- | client/macrowindow.h | 2 |
4 files changed, 20 insertions, 24 deletions
diff --git a/client/lua.cc b/client/lua.cc index 7dbdf75..3dd5381 100644 --- a/client/lua.cc +++ b/client/lua.cc @@ -75,6 +75,19 @@ LUA::LUA(Widget **rootwidget) { this->rootwidget = rootwidget; + L = NULL; + clear(); +} + +LUA::~LUA() +{ + lua_close(L); +} + +void LUA::clear() +{ + if(L) lua_close(L); + L = luaL_newstate(); if(L == NULL) { error("Could not create LUA state."); @@ -91,11 +104,6 @@ LUA::LUA(Widget **rootwidget) register_widget(L); } -LUA::~LUA() -{ - lua_close(L); -} - QString LUA::runParser(QString program) { if(L == NULL) { diff --git a/client/lua.h b/client/lua.h index d10aeb2..d94bd15 100644 --- a/client/lua.h +++ b/client/lua.h @@ -47,6 +47,8 @@ public: Widget *getWidget(QString name); + void clear(); + private: lua_State *L; Widget **rootwidget; diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 649f323..5a6760e 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -47,7 +47,7 @@ MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString templ, : Collapser(), netcom(n) { mainwidget = NULL; - this->lua = new LUA(&mainwidget); + lua = new LUA(&mainwidget); waschanged = false; @@ -65,7 +65,6 @@ MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString templ, MacroWindow::~MacroWindow() { clear(); - delete lua; } void MacroWindow::update(QDomNode &node) @@ -101,7 +100,7 @@ void MacroWindow::initMacro(QDomNode &node) } else if(xml_elem.tagName() == "script") { if(xml_elem.attribute("language", "lua") == "lua") { - this->lua->runScript(xml_elem.text(), NULL, "preload"); + lua->runScript(xml_elem.text(), NULL, "preload"); } } else if(xml_elem.tagName() == "widgets") { @@ -118,15 +117,6 @@ void MacroWindow::initMacro(QDomNode &node) mainwidget = window; mainwidget->setValues(); - /* - QDomNodeList children = node.childNodes(); - - // Insert their values (this must be done last for scripts to work properly) - for (int i=0; i<children.count();i++) { - QDomNode child = children.at(i); - setValues(child, mainwidget); - } - */ if(waschanged == true) macroChanged(); @@ -188,8 +178,6 @@ void MacroWindow::expandWrapper() { if(!isCollapsed()) return; - // clear(); - waschanged = false; QDomDocument xml_doc = netcom.send(templ, macro); @@ -300,11 +288,11 @@ void MacroWindow::setActive(bool active) void MacroWindow::clear() { - if(mainwidget) mainwidget->deleteLater(); + if(mainwidget) delete mainwidget; mainwidget = NULL; - setExpandedWidget(NULL); + lua->clear(); - luaprograms.clear(); + setExpandedWidget(NULL); } diff --git a/client/macrowindow.h b/client/macrowindow.h index 3bc02f2..02370dd 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -44,8 +44,6 @@ public: bool collapsed = true, bool compact = false); ~MacroWindow(); - QVector< QString > luaprograms; - LUA *lua; void update(QDomNode &xml_doc); |