summaryrefslogtreecommitdiff
path: root/client/widgets/widget.cc
diff options
context:
space:
mode:
authordeva <deva>2010-08-13 07:58:49 +0000
committerdeva <deva>2010-08-13 07:58:49 +0000
commitbc229dbfabdf6a59453605e7652f04a268605b3a (patch)
tree949c083efc8a06e1b55fa9440cc100d2b235215d /client/widgets/widget.cc
parentd9338083192084613e5530b02710b796252d342b (diff)
Memory cleanup bug, fixed.
Diffstat (limited to 'client/widgets/widget.cc')
-rw-r--r--client/widgets/widget.cc22
1 files changed, 12 insertions, 10 deletions
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++;
}