aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2011-12-25 16:23:40 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:50 +0100
commit0f42e8231f3af3d518a5c438ec41a3d849d37a29 (patch)
tree1834b85fb3d1c024854212e324bc588ae9738b10 /src/menu
parent136bea6e38b02a6b47f8722a863d9ead06c07720 (diff)
downloadusdx-0f42e8231f3af3d518a5c438ec41a3d849d37a29.tar.gz
usdx-0f42e8231f3af3d518a5c438ec41a3d849d37a29.tar.xz
usdx-0f42e8231f3af3d518a5c438ec41a3d849d37a29.zip
menu/control: fix segfaults if manually deletes a control
Diffstat (limited to 'src/menu')
-rw-r--r--src/menu/control.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/menu/control.cpp b/src/menu/control.cpp
index b22df1ab..bea054ee 100644
--- a/src/menu/control.cpp
+++ b/src/menu/control.cpp
@@ -31,7 +31,9 @@ namespace usdx
Control::Control(Control *owner)
: owner(owner)
{
- owner->add(this);
+ if (owner) {
+ owner->add(this);
+ }
}
Control::~Control()
@@ -42,14 +44,23 @@ namespace usdx
}
slaves.clear();
+
+ // remove object from owners list, to avoid double free
+ set_owner(NULL);
}
void Control::set_owner(Control *owner)
{
if (this->owner != owner) {
- this->owner->remove(this);
+ if (this->owner) {
+ this->owner->remove(this);
+ }
+
this->owner = owner;
- this->owner->add(this);
+
+ if (this->owner) {
+ this->owner->add(this);
+ }
}
}