aboutsummaryrefslogtreecommitdiff
path: root/dw/layout.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/layout.cc')
-rw-r--r--dw/layout.cc24
1 files changed, 21 insertions, 3 deletions
diff --git a/dw/layout.cc b/dw/layout.cc
index 542b8ea4..f16cbae7 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -308,9 +308,7 @@ Layout::~Layout ()
if (bgImage)
bgImage->unref ();
if (topLevel) {
- // Sometimes, the toplevel widget does some stuff after the
- // layout has been deleted.
- topLevel->layout = NULL;
+ detachWidget (topLevel);
Widget *w = topLevel;
topLevel = NULL;
delete w;
@@ -326,6 +324,26 @@ Layout::~Layout ()
DBG_OBJ_DELETE ();
}
+void Layout::detachWidget (Widget *widget)
+{
+ // Called form ~Layout. Sometimes, the widgets (not only the toplevel widget)
+ // do some stuff after the layout has been deleted, so *all* widgets have to
+ // be detached, and check "layout != NULL" at relevant points.
+
+ // Could be replaced by a virtual method in Widget, like getWidgetAtPoint,
+ // if performace were really a problem.
+
+ widget->layout = NULL;
+ Iterator *it =
+ widget->iterator ((Content::Type)
+ (Content::WIDGET_IN_FLOW | Content::WIDGET_OOF_CONT),
+ false);
+ while (it->next ())
+ detachWidget (it->getContent()->widget);
+
+ it->unref ();
+}
+
void Layout::addWidget (Widget *widget)
{
if (topLevel) {