diff options
author | deva <deva> | 2010-08-13 11:56:34 +0000 |
---|---|---|
committer | deva <deva> | 2010-08-13 11:56:34 +0000 |
commit | c58541468c5477323e35837a8f0aeaf41e5a0794 (patch) | |
tree | 4a215de3b61bf3a521edf2e6f67f00c3731b6dc7 /client | |
parent | 51122d8689f6fbb1061ee0b19f885ad8851dfd50 (diff) |
Fix one too many resets of the LUA stack.
Diffstat (limited to 'client')
-rw-r--r-- | client/lua.cc | 19 | ||||
-rw-r--r-- | client/macrowindow.cc | 28 | ||||
-rw-r--r-- | client/macrowindow.h | 3 | ||||
-rw-r--r-- | client/netcom.cc | 10 | ||||
-rw-r--r-- | client/widgets/button.cc | 1 | ||||
-rw-r--r-- | client/widgets/checkbox.cc | 1 | ||||
-rw-r--r-- | client/widgets/lineedit.cc | 1 | ||||
-rw-r--r-- | client/widgets/widget.cc | 27 | ||||
-rw-r--r-- | client/widgets/window.cc | 10 |
9 files changed, 67 insertions, 33 deletions
diff --git a/client/lua.cc b/client/lua.cc index 3dd5381..062e520 100644 --- a/client/lua.cc +++ b/client/lua.cc @@ -32,6 +32,9 @@ #include "luawidget.h" +#define DEBUG(fmt...) printf("LUA (%p)", this); printf(fmt); fflush(stdout) +//#define DEBUG(ftm...) + #define GLOBAL_POINTER "_pracroGlobalLUAObjectPointerThisShouldBeANameThatIsNotAccidentallyOverwritten" static int get_widget(lua_State *L) @@ -58,7 +61,7 @@ static int get_widget(lua_State *L) Widget *widget = lua->getWidget(name); - // printf("FIND: %s (%p)\n", name.toStdString().c_str(), widget); + // DEBUG("FIND: %s (%p)\n", name.toStdString().c_str(), widget); if(widget) { wdg_make_widget(L, widget); @@ -66,7 +69,7 @@ static int get_widget(lua_State *L) lua_pushnil(L); } - // printf("DONE\n"); + // DEBUG("DONE\n"); return 1; } @@ -111,7 +114,7 @@ QString LUA::runParser(QString program) return false; } - printf("Running %s\n", program.toStdString().c_str()); + DEBUG("Running %s\n", program.toStdString().c_str()); int top = lua_gettop(L); @@ -152,10 +155,10 @@ bool LUA::runScript(QString script, Widget *widget, QString name) return false; } - printf("Running %s script %s on %s widget.\n", - name.toStdString().c_str(), - script.toStdString().c_str(), - widget?widget->name().toStdString().c_str():"NULL"); + DEBUG("Running %s script %s on %s widget.\n", + name.toStdString().c_str(), + script.toStdString().c_str(), + widget?widget->name().toStdString().c_str():"NULL"); if(widget) { wdg_make_widget(L, widget); @@ -181,7 +184,7 @@ bool LUA::runScript(QString script, Widget *widget, QString name) void LUA::error(QString message) { - printf("LUA ERROR: %s\n", message.toStdString().c_str()); + DEBUG("LUA ERROR: %s\n", message.toStdString().c_str()); } Widget *LUA::getWidget(QString name) diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 5a6760e..f8c9af6 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -42,10 +42,16 @@ extern QString user; extern QString host; extern quint16 port; +#define DEBUG(fmt...) printf("MacroWindow (%p)", this); \ + printf(fmt); fflush(stdout) +//#define DEBUG(ftm...) + MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString templ, bool collapsed, bool compact) : Collapser(), netcom(n) { + DEBUG("macrowindow %p\n", this); + mainwidget = NULL; lua = new LUA(&mainwidget); @@ -55,11 +61,12 @@ MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString templ, setCollapsedWidget(new ResumeWidget(compact)); - update(xml_doc); setCollapsed(collapsed); active = true; + + connect(this, SIGNAL(doneCollapsing()), this, SLOT(collapsed())); } MacroWindow::~MacroWindow() @@ -69,6 +76,9 @@ MacroWindow::~MacroWindow() void MacroWindow::update(QDomNode &node) { + clear(); + lua->clear(); + initMacro(node); if(mainwidget) setExpandedWidget(mainwidget->qwidget()); @@ -106,7 +116,7 @@ void MacroWindow::initMacro(QDomNode &node) } else if(xml_elem.tagName() == "widgets") { if(mainwidget) { - printf("ERROR!!!!!!\n\tmainwidget already exists!\n"); + DEBUG("ERROR!!!!!!\n\tmainwidget already exists!\n"); } Window *window = new Window(xml_elem, this); @@ -271,7 +281,7 @@ void MacroWindow::toggleMacro() void MacroWindow::macroChanged() { - printf("This macro was changed!\n"); + DEBUG("This macro was changed!\n"); emit macroHasChanged(); waschanged = true; } @@ -288,11 +298,17 @@ void MacroWindow::setActive(bool active) void MacroWindow::clear() { + DEBUG("clear %p\n", this); + setExpandedWidget(NULL); + if(mainwidget) delete mainwidget; mainwidget = NULL; - lua->clear(); - - setExpandedWidget(NULL); + // lua->clear(); } +void MacroWindow::collapsed() +{ + DEBUG("collapsed %p\n", this); + clear(); +} diff --git a/client/macrowindow.h b/client/macrowindow.h index 02370dd..dc60ccc 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -68,6 +68,9 @@ signals: void macroHasChanged(); void activationChanged(bool); +private slots: + void collapsed(); + private: void initMacro(QDomNode &node); diff --git a/client/netcom.cc b/client/netcom.cc index a606c62..02c5704 100644 --- a/client/netcom.cc +++ b/client/netcom.cc @@ -48,8 +48,8 @@ #endif #endif -#define DEBUG(fmt...) printf(fmt) -//#define DEBUG(ftm...) +//#define DEBUG(fmt...) printf(fmt) +#define DEBUG(ftm...) NetCom::NetCom(QString host, quint16 port) { @@ -191,10 +191,11 @@ QDomDocument NetCom::send(QVector< Widget* > widgets, QString templ, // Iterate the different entries, and append their results to // the commit string QVector< Widget* >::iterator i = widgets.begin(); - while (i != widgets.end()) { + while(i != widgets.end()) { + DEBUG("W = "); if(*i) { Widget* w = *i; - DEBUG("W: %s: %s\n", w->name().toStdString().c_str(), + DEBUG("name: %s val: %s", w->name().toStdString().c_str(), w->value().toStdString().c_str()); if(w->enabled() && w->name() != "" && w->local() == false) { QDomElement field_elem = doc.createElement("field"); @@ -203,6 +204,7 @@ QDomDocument NetCom::send(QVector< Widget* > widgets, QString templ, commit_elem.appendChild(field_elem); } } + DEBUG("\n"); i++; } diff --git a/client/widgets/button.cc b/client/widgets/button.cc index 3234296..6e809fe 100644 --- a/client/widgets/button.cc +++ b/client/widgets/button.cc @@ -64,7 +64,6 @@ Button::Button(QDomNode &node, MacroWindow *macrowindow) Button::~Button() { - printf("Delete (Button) %p\n", this); fflush(stdout); // delete button; } diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc index 19b59e6..af7d68f 100644 --- a/client/widgets/checkbox.cc +++ b/client/widgets/checkbox.cc @@ -63,7 +63,6 @@ CheckBox::CheckBox(QDomNode &node, MacroWindow *macrowindow) CheckBox::~CheckBox() { - printf("Delete (CheckBox) %p\n", this); fflush(stdout); // delete checkbox; } diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 6b231f3..cddd59e 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -65,7 +65,6 @@ LineEdit::LineEdit(QDomNode &node, MacroWindow *macrowindow) LineEdit::~LineEdit() { - printf("Delete (LineEdit) %p\n", this); fflush(stdout); // delete lineedit; } diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index f3247a0..cd29d0a 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -33,10 +33,15 @@ #include <QLayout> #include <QObject> +//#define DEBUG(fmt...) printf(fmt) +#define DEBUG(ftm...) + Widget::Widget(QDomNode &node, MacroWindow *macrowindow) { widget = NULL; + hideChildren = false; + QDomElement elem = node.toElement(); this->macrowindow = macrowindow; @@ -65,16 +70,16 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow) is_valid = true; - printf("Create Widget '%s' of type '%s'\n", - name().toStdString().c_str(), - type().toStdString().c_str()); + DEBUG("Create Widget '%s' of type '%s'\n", + name().toStdString().c_str(), + type().toStdString().c_str()); } Widget::~Widget() { - printf("Delete Widget '%s' of type '%s'\n", - name().toStdString().c_str(), - type().toStdString().c_str()); + DEBUG("Delete Widget '%s' of type '%s'\n", + name().toStdString().c_str(), + type().toStdString().c_str()); QVector< Widget* >::iterator i = children.begin(); while(i != children.end()) { @@ -178,7 +183,7 @@ bool Widget::setKeyboardFocus() Widget *Widget::findWidget(QString n, bool deep) { - printf("Find Widget %p\n", this); fflush(stdout); + DEBUG("Find Widget %p\n", this); fflush(stdout); if(n == name()) return this; @@ -198,9 +203,11 @@ Widget *Widget::findWidget(QString n, bool deep) QVector< Widget* > Widget::widgetList(bool deep) { - printf("Widget List %p\n", this); fflush(stdout); + DEBUG("Widget List %p\n", this); fflush(stdout); + + QVector< Widget* > lst; - QVector< Widget* > lst = children; + lst.push_back(this); if(hideChildren && deep == false) return lst; @@ -221,7 +228,7 @@ void Widget::childWasChanged() void Widget::addChild(Widget *widget) { if(widget == NULL) { - printf("Trying to add NULL child to '%s'\n", name().toStdString().c_str()); + DEBUG("Trying to add NULL child to '%s'\n", name().toStdString().c_str()); return; } children.push_back(widget); diff --git a/client/widgets/window.cc b/client/widgets/window.cc index 4d9253d..b480189 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -30,9 +30,14 @@ #include <QWidget> #include <QIcon> +//#define DEBUG(fmt...) printf(fmt) +#define DEBUG(ftm...) + Window::Window(QDomNode &node, MacroWindow *macrowindow) : Widget(node, macrowindow) { + DEBUG("window\n"); + widget = new QWidget(NULL); widget->setWindowFlags(Qt::WindowContextHelpButtonHint | @@ -60,6 +65,7 @@ Window::Window(QDomNode &node, MacroWindow *macrowindow) Window::~Window() { - printf("Delete (Window) %p\n", this); fflush(stdout); - // delete widget; + DEBUG("~window\n"); + + //delete widget; } |