aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu
diff options
context:
space:
mode:
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);
+ }
}
}