From 26dc58fb696ac1f96e018fbae7083d1ba2a1a55a Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 4 Sep 2008 12:25:09 +0000 Subject: Made macrowindow clean up proprely when closed (thus terminating dangling db connections through dbwidget). --- client/formatparser.cc | 15 +++++---------- client/macrowindow.cc | 17 ++++++++++++++++- client/widgets/dbwidget.cc | 1 + 3 files changed, 22 insertions(+), 11 deletions(-) (limited to 'client') diff --git a/client/formatparser.cc b/client/formatparser.cc index 233a694..0f04d0a 100644 --- a/client/formatparser.cc +++ b/client/formatparser.cc @@ -127,17 +127,12 @@ QString format_parser(QString format, QSqlQuery &query) p++; } { - int fieldNo = query.record().indexOf(var); - resume += query.value(fieldNo).toString(); - - /* - QVector< Widget* >::iterator i = widgets.begin(); - while (i != widgets.end()) { - Widget* w = *i; - if(w->getName() == var) resume += w->getValue(); - i++; + int idx = query.record().indexOf(var); + if(idx == -1) { + printf("Unknown field in format string %s\n", var.toStdString().c_str()); + } else { + resume += query.value(idx).toString(); } - */ } break; diff --git a/client/macrowindow.cc b/client/macrowindow.cc index b0eab65..5ef342d 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -61,6 +61,21 @@ MacroWindow::MacroWindow(QDomNode &xml_doc) MacroWindow::~MacroWindow() { delete lua; + + QVector< Widget* >::iterator i = widgets.begin(); + while (i != widgets.end()) { + Widget* w = *i; + delete w; + i++; + } + + QVector< Widget* >::iterator j = auxwidgets.begin(); + while (j != auxwidgets.end()) { + Widget* w = *j; + delete w; + j++; + } + } void MacroWindow::initMacro(QDomNode &node) @@ -200,7 +215,7 @@ void MacroWindow::cont(QString name) bool MacroWindow::isClosed() { - return isclosed; + return isclosed || mainwidget->isVisible() == false; } Widget *MacroWindow::getWidget(QString name) diff --git a/client/widgets/dbwidget.cc b/client/widgets/dbwidget.cc index 69c868e..1c0a0d2 100644 --- a/client/widgets/dbwidget.cc +++ b/client/widgets/dbwidget.cc @@ -94,6 +94,7 @@ DBWidget::DBWidget(QDomNode &node, MacroWindow *macrowindow) DBWidget::~DBWidget() { db.close(); + db = QSqlDatabase(); } -- cgit v1.2.3