summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-11-11 11:14:20 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-11-11 11:14:20 +0800
commit4badbcd457e420cc1aa580e877e3c1fcd6e31100 (patch)
tree0b7fc51b6d5e66a472c040d9f734f33c88c07c47 /src
parent87a93df4661f175e08f934ec525a0d8844fec5ec (diff)
downloadunity-window-decorator-4badbcd457e420cc1aa580e877e3c1fcd6e31100.tar.gz
unity-window-decorator-4badbcd457e420cc1aa580e877e3c1fcd6e31100.tar.bz2
Make sure that we properly unregister actions when removing the option private with operator=
Diffstat (limited to 'src')
-rw-r--r--src/option.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/option.cpp b/src/option.cpp
index 78fdc0f..36ad066 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -406,12 +406,38 @@ CompOption::Value::operator!= (const CompOption::Value &val)
return !(*this == val);
}
+static void
+finiOptionValue (CompOption::Value &v,
+ CompOption::Type type)
+{
+ switch (type) {
+ case CompOption::TypeAction:
+ case CompOption::TypeKey:
+ case CompOption::TypeButton:
+ case CompOption::TypeEdge:
+ case CompOption::TypeBell:
+ if (v.action ().state () & CompAction::StateAutoGrab && screen)
+ screen->removeAction (&v.action ());
+ break;
+
+ case CompOption::TypeList:
+ foreach (CompOption::Value &val, v.list ())
+ finiOptionValue (val, v.listType ());
+ break;
+
+ default:
+ break;
+ }
+}
+
CompOption::Value &
CompOption::Value::operator= (const CompOption::Value &val)
{
if (this == &val)
return *this;
+ finiOptionValue (*this, priv->type);
+
delete priv;
priv = new PrivateValue (*val.priv);
@@ -661,30 +687,6 @@ finiScreenOptionValue (CompScreen *s,
}
}
-static void
-finiOptionValue (CompOption::Value &v,
- CompOption::Type type)
-{
- switch (type) {
- case CompOption::TypeAction:
- case CompOption::TypeKey:
- case CompOption::TypeButton:
- case CompOption::TypeEdge:
- case CompOption::TypeBell:
- if (v.action ().state () & CompAction::StateAutoGrab && screen)
- screen->removeAction (&v.action ());
- break;
-
- case CompOption::TypeList:
- foreach (CompOption::Value &val, v.list ())
- finiOptionValue (val, v.listType ());
- break;
-
- default:
- break;
- }
-}
-
CompOption::~CompOption ()
{
finiOptionValue (priv->value, priv->type);