diff --git a/deleted.cpp b/deleted.cpp index 59bf1eb34d..08c1142f67 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -47,11 +47,16 @@ void Deleted::copyToDeleted( Toplevel* c ) cinfo->disable(); } -void Deleted::unrefWindow() +void Deleted::unrefWindow( bool delay ) { if( --delete_refcount > 0 ) return; - deleteLater(); + // 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; } int Deleted::desktop() const diff --git a/deleted.h b/deleted.h index e486eddc82..d8a3bba78a 100644 --- a/deleted.h +++ b/deleted.h @@ -24,7 +24,7 @@ class Deleted 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(); + void unrefWindow( bool delay = false ); virtual int desktop() const; protected: virtual void debug( kdbgstream& stream ) const; diff --git a/effects.cpp b/effects.cpp index 538978fc5d..17d094f035 100644 --- a/effects.cpp +++ b/effects.cpp @@ -791,7 +791,7 @@ void EffectWindowImpl::refWindow() void EffectWindowImpl::unrefWindow() { if( Deleted* d = dynamic_cast< Deleted* >( toplevel )) - return d->unrefWindow(); + return d->unrefWindow( true ); // delayed abort(); // TODO } diff --git a/main.cpp b/main.cpp index 83f232d135..5ad388e9cb 100644 --- a/main.cpp +++ b/main.cpp @@ -153,6 +153,7 @@ Application::~Application() void Application::lostSelection() { + sendPostedEvents(); delete Workspace::self(); // remove windowmanager privileges XSelectInput(display(), rootWindow(), PropertyChangeMask );