diff --git a/deleted.cpp b/deleted.cpp index 5f505b62c5..de26ae18e4 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -107,16 +107,15 @@ void Deleted::copyToDeleted(Toplevel* c) } } -void Deleted::unrefWindow(bool delay) +void Deleted::unrefWindow() { if (--delete_refcount > 0) return; - // needs to be delayed when calling from effects, otherwise it'd be rather - // complicated to handle the case of the window going away during a painting pass - if (delay) - deleteLater(); - else - delete this; + // needs to be delayed + // a) when calling from effects, otherwise it'd be rather complicated to handle the case of the + // window going away during a painting pass + // b) to prevent dangeling pointers in the stacking order, see bug #317765 + deleteLater(); } int Deleted::desktop() const diff --git a/deleted.h b/deleted.h index 53b45bb97d..69fb50e0dc 100644 --- a/deleted.h +++ b/deleted.h @@ -37,7 +37,7 @@ public: static Deleted* create(Toplevel* c); // used by effects to keep the window around for e.g. fadeout effects when it's destroyed void refWindow(); - void unrefWindow(bool delay = false); + void unrefWindow(); void discard(); virtual int desktop() const; virtual QStringList activities() const; diff --git a/effects.cpp b/effects.cpp index 1cd7a0354c..b5f87402ce 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1662,7 +1662,7 @@ void EffectWindowImpl::refWindow() void EffectWindowImpl::unrefWindow() { if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) - return d->unrefWindow(true); // delayed + return d->unrefWindow(); // delays deletion in case abort(); // TODO }