diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-03-22 22:49:14 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-13 22:40:51 +0100 |
commit | b44ac46e4e54f228fd9c25c042da2efd2ab45b64 (patch) | |
tree | 558fe562a65f7608485fd0453f2f0403b3a73fb2 | |
parent | ce83bbe3db755828faea0490ede53f8889ba0254 (diff) | |
download | usdx-b44ac46e4e54f228fd9c25c042da2efd2ab45b64.tar.gz usdx-b44ac46e4e54f228fd9c25c042da2efd2ab45b64.tar.xz usdx-b44ac46e4e54f228fd9c25c042da2efd2ab45b64.zip |
menu/container: cleanup while destruction of container
while a container is destructed, the parent of all containing
controls will be removed, so that the controls it self do not try to
unregister itself from the destroyed container later (while
destruction the control class of the container and destroying all
slave controls)
Diffstat (limited to '')
-rw-r--r-- | src/menu/container.cpp | 5 | ||||
-rw-r--r-- | src/menu/drawable_control.cpp | 13 | ||||
-rw-r--r-- | src/menu/drawable_control.hpp | 2 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/menu/container.cpp b/src/menu/container.cpp index 4ac26548..795d57ab 100644 --- a/src/menu/container.cpp +++ b/src/menu/container.cpp @@ -46,6 +46,11 @@ namespace usdx Container::~Container() { + for (std::list<DrawableControl*>::iterator next = controls.begin(), it = next++; + it != controls.end(); it = next++) { + (*it)->remove_parent(); + } + controls.clear(); } diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp index 72486d42..00b6fa78 100644 --- a/src/menu/drawable_control.cpp +++ b/src/menu/drawable_control.cpp @@ -52,10 +52,7 @@ namespace usdx DrawableControl::~DrawableControl() { - if (parent) { - parent->remove(this); - parent = NULL; - } + remove_parent(); } bool DrawableControl::get_clipping_required(void) const @@ -151,6 +148,14 @@ namespace usdx return size.get_height(); } + void DrawableControl::remove_parent(void) + { + if (parent) { + parent->remove(this); + parent = NULL; + } + } + DrawableControl::ContainerHelper::ContainerHelper(DrawableControl* self) : self(self) { diff --git a/src/menu/drawable_control.hpp b/src/menu/drawable_control.hpp index 64bd5a24..2acdd7ec 100644 --- a/src/menu/drawable_control.hpp +++ b/src/menu/drawable_control.hpp @@ -90,6 +90,8 @@ namespace usdx const Dimension<int>& get_size(void) const; int get_width(void) const; int get_height(void) const; + + void remove_parent(void); }; }; |