From bc229dbfabdf6a59453605e7652f04a268605b3a Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 13 Aug 2010 07:58:49 +0000 Subject: Memory cleanup bug, fixed. --- client/widgets/lineedit.cc | 5 +++-- client/widgets/widget.cc | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'client/widgets') diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 918f152..6b231f3 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -89,8 +89,9 @@ void LineEdit::setValue(QString value, QString source) { if(isUserSource(source)) emit wasChanged(); - if(lineedit->text() == value) - lineedit->setText(value + " "); // Hack to make sure the textChanged signal is emitted. + // Hack to make sure the textChanged signal is emitted. + if(lineedit->text() == value) lineedit->setText(value + " "); + lineedit->setText(value); setInitialValue(value); diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index af03843..2205beb 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -75,12 +75,6 @@ Widget::~Widget() name().toStdString().c_str(), type().toStdString().c_str()); - /* // This is done by Qt - if(widget) { - delete widget; - widget = NULL; - } - */ QVector< Widget* >::iterator i = children.begin(); while(i != children.end()) { if(*i) delete *i; @@ -88,6 +82,12 @@ Widget::~Widget() } children.clear(); + + // This MUST be done after the deletion of the children Widget list. + if(widget) { + delete widget; + widget = NULL; + } } void Widget::addChildren(QDomNode &node) @@ -121,7 +121,7 @@ bool Widget::valid() QVector< Widget* >::iterator i = children.begin(); while(i != children.end()) { - if((*i)->valid() == false) return false; + if(*i && (*i)->valid() == false) return false; i++; } @@ -194,8 +194,10 @@ Widget *Widget::findWidget(QString n, bool deep) QVector< Widget* >::iterator i = children.begin(); while(i != children.end()) { - Widget *w = (*i)->findWidget(n, deep); - if(w) return w; + if(*i) { + Widget *w = (*i)->findWidget(n, deep); + if(w) return w; + } i++; } @@ -212,7 +214,7 @@ QVector< Widget* > Widget::widgetList(bool deep) QVector< Widget* >::iterator i = children.begin(); while(i != children.end()) { - lst += (*i)->widgetList(deep); + if(*i) lst += (*i)->widgetList(deep); i++; } -- cgit v1.2.3