summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2010-08-13 10:07:22 +0000
committerdeva <deva>2010-08-13 10:07:22 +0000
commit51122d8689f6fbb1061ee0b19f885ad8851dfd50 (patch)
treec0513a8df0eda183226909fccc8b38e3f6e79185 /client
parentc4ecebb7a1f33acb38d51a82788b071186ff3c19 (diff)
Clear lua when reopening a macro window.
Diffstat (limited to 'client')
-rw-r--r--client/lua.cc18
-rw-r--r--client/lua.h2
-rw-r--r--client/macrowindow.cc22
-rw-r--r--client/macrowindow.h2
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);