aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-11-07 14:50:32 +0000
committerMax Horn2003-11-07 14:50:32 +0000
commit767fc8714804f938de79ef7bc916d3df684f039c (patch)
treec39cff7b5951a6a216888f9ee8256bfa6bee2b36
parent496d19d46176200c3d8486a202382b7016591f5c (diff)
downloadscummvm-rg350-767fc8714804f938de79ef7bc916d3df684f039c.tar.gz
scummvm-rg350-767fc8714804f938de79ef7bc916d3df684f039c.tar.bz2
scummvm-rg350-767fc8714804f938de79ef7bc916d3df684f039c.zip
fixed memory leak in TabWidget
svn-id: r11191
-rw-r--r--gui/TabWidget.cpp8
-rw-r--r--gui/TabWidget.h1
-rw-r--r--gui/dialog.cpp8
-rw-r--r--gui/widget.cpp4
-rw-r--r--gui/widget.h2
5 files changed, 15 insertions, 8 deletions
diff --git a/gui/TabWidget.cpp b/gui/TabWidget.cpp
index 61560a9d47..934179a441 100644
--- a/gui/TabWidget.cpp
+++ b/gui/TabWidget.cpp
@@ -42,6 +42,14 @@ TabWidget::TabWidget(GuiObject *boss, int x, int y, int w, int h)
_tabWidth = 40;
}
+TabWidget::~TabWidget() {
+ for (int i = 0; i < _tabs.size(); ++i) {
+ delete _tabs[i].firstWidget;
+ _tabs[i].firstWidget = 0;
+ }
+ _tabs.clear();
+}
+
int16 TabWidget::getChildY() const {
return getAbsY() + kTabHeight;
}
diff --git a/gui/TabWidget.h b/gui/TabWidget.h
index 1f71fe2063..938da76513 100644
--- a/gui/TabWidget.h
+++ b/gui/TabWidget.h
@@ -39,6 +39,7 @@ protected:
public:
TabWidget(GuiObject *boss, int x, int y, int w, int h);
+ ~TabWidget();
virtual int16 getChildY() const;
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 2cd6848d0b..f5d2c22250 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -35,13 +35,7 @@
*/
Dialog::~Dialog() {
- Widget *w = _firstWidget, *next;
- while (w) {
- next = w->_next;
- w->_next = 0;
- delete w;
- w = next;
- }
+ delete _firstWidget;
_firstWidget = 0;
}
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 41926de51f..f876006c96 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -33,6 +33,10 @@ Widget::Widget(GuiObject *boss, int x, int y, int w, int h)
_boss->_firstWidget = this;
}
+Widget::~Widget() {
+ delete _next;
+}
+
void Widget::draw() {
NewGui *gui = &g_gui;
diff --git a/gui/widget.h b/gui/widget.h
index 37382c1914..4a7bc3a021 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -78,7 +78,7 @@ public:
public:
Widget(GuiObject *boss, int x, int y, int w, int h);
- virtual ~Widget() {}
+ virtual ~Widget();
virtual int16 getAbsX() const { return _x + _boss->getChildX(); }
virtual int16 getAbsY() const { return _y + _boss->getChildY(); }