| author | Sam Spilsbury <smspillaz@gmail.com> | 2009-11-26 04:41:53 (GMT) |
|---|---|---|
| committer | Sam Spilsbury <smspillaz@gmail.com> | 2009-11-26 04:41:53 (GMT) |
| commit | cd3cc22c57bae95f232db324b63bebc6bd4334c5 (patch) (side-by-side diff) | |
| tree | cc060f78c2cefa5ab90a979715d9126c638f98c8 | |
| parent | d70f6a38c3e8067b8721981adad80ed40d2ba42f (diff) | |
| download | elements-cd3cc22c57bae95f232db324b63bebc6bd4334c5.tar.gz elements-cd3cc22c57bae95f232db324b63bebc6bd4334c5.tar.bz2 | |
Fix crash by resetting list traversal when deleting elements in the list
| -rw-r--r-- | include/elements/elements.h | 6 | ||||
| -rw-r--r-- | plugins/autumn/src/autumn.cpp | 2 | ||||
| -rw-r--r-- | plugins/bubbles/src/bubbles.cpp | 2 | ||||
| -rw-r--r-- | plugins/fireflies/src/fireflies.cpp | 2 | ||||
| -rw-r--r-- | plugins/snow/src/snow.cpp | 2 | ||||
| -rw-r--r-- | plugins/stars/src/stars.cpp | 2 | ||||
| -rw-r--r-- | src/element.cpp | 1 | ||||
| -rw-r--r-- | src/type.cpp | 21 |
8 files changed, 27 insertions, 11 deletions
diff --git a/include/elements/elements.h b/include/elements/elements.h index 3b76ff0..50f1e18 100644 --- a/include/elements/elements.h +++ b/include/elements/elements.h @@ -219,8 +219,6 @@ class ElementType { public: - ~ElementType (); - void setName (CompString, CompString); @@ -242,11 +240,15 @@ class ElementType static ElementType * create (); + void + destroy (); + elementAddFunc addFunc; private: ElementType (); ElementType (CompString, CompString, elementAddFunc); + ~ElementType (); CompString mName; CompString mDesc; diff --git a/plugins/autumn/src/autumn.cpp b/plugins/autumn/src/autumn.cpp index e5af769..27a33ea 100644 --- a/plugins/autumn/src/autumn.cpp +++ b/plugins/autumn/src/autumn.cpp @@ -109,7 +109,7 @@ AutumnScreen::AutumnScreen (CompScreen *) : AutumnScreen::~AutumnScreen () { - delete type; + type->destroy (); } bool diff --git a/plugins/bubbles/src/bubbles.cpp b/plugins/bubbles/src/bubbles.cpp index 5053bd4..8cf20b0 100644 --- a/plugins/bubbles/src/bubbles.cpp +++ b/plugins/bubbles/src/bubbles.cpp @@ -89,7 +89,7 @@ BubbleScreen::BubbleScreen (CompScreen *screen) : BubbleScreen::~BubbleScreen () { - delete type; + type->destroy (); } bool diff --git a/plugins/fireflies/src/fireflies.cpp b/plugins/fireflies/src/fireflies.cpp index 8087c32..0276133 100644 --- a/plugins/fireflies/src/fireflies.cpp +++ b/plugins/fireflies/src/fireflies.cpp @@ -102,7 +102,7 @@ FirefliesScreen::FirefliesScreen (CompScreen *screen) : FirefliesScreen::~FirefliesScreen () { - delete type; + type->destroy (); } void diff --git a/plugins/snow/src/snow.cpp b/plugins/snow/src/snow.cpp index 3b72dd2..6084a6d 100644 --- a/plugins/snow/src/snow.cpp +++ b/plugins/snow/src/snow.cpp @@ -90,7 +90,7 @@ SnowScreen::SnowScreen (CompScreen *screen) : SnowScreen::~SnowScreen () { - delete type; + type->destroy (); } bool diff --git a/plugins/stars/src/stars.cpp b/plugins/stars/src/stars.cpp index 0d2cfbe..9729bb1 100644 --- a/plugins/stars/src/stars.cpp +++ b/plugins/stars/src/stars.cpp @@ -88,7 +88,7 @@ StarScreen::StarScreen (CompScreen *screen) : StarScreen::~StarScreen () { - delete type; + type->destroy (); } void diff --git a/src/element.cpp b/src/element.cpp index ea4b4e6..e5eb21e 100644 --- a/src/element.cpp +++ b/src/element.cpp @@ -102,5 +102,4 @@ Element::move () void Element::fini () { - delete ((Element *) this); } diff --git a/src/type.cpp b/src/type.cpp index 14d269a..6cb7b25 100644 --- a/src/type.cpp +++ b/src/type.cpp @@ -68,15 +68,30 @@ ElementType::~ElementType () { ELEMENTS_SCREEN (screen); - foreach (ElementAnimation *anim, es->priv->animations) + es->priv->types.remove ((ElementType_ *) this); + + delete this; +} + +void +ElementType::destroy () +{ + ELEMENTS_SCREEN (screen); + + std::list<ElementAnimation *>::iterator it = es->priv->animations.begin (); + + while (it != es->priv->animations.end ()) { + ElementAnimation *anim = *it; + if (this == anim->type ()) { delete anim; + it = es->priv->animations.begin (); } + else + it++; } - - es->priv->types.remove ((ElementType_ *) this); } ElementType * |
