Avoid crashes during shutdown.

svn path=/trunk/KDE/kdebase/workspace/; revision=662929
This commit is contained in:
Luboš Luňák 2007-05-09 16:10:49 +00:00
parent d83256ae1f
commit d1b6aaacdf
4 changed files with 10 additions and 4 deletions

View file

@ -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

View file

@ -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;

View file

@ -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
}

View file

@ -153,6 +153,7 @@ Application::~Application()
void Application::lostSelection()
{
sendPostedEvents();
delete Workspace::self();
// remove windowmanager privileges
XSelectInput(display(), rootWindow(), PropertyChangeMask );