Merging from old trunk:
r613847 | lunakl | 2006-12-15 14:01:19 +0100 (Fri, 15 Dec 2006) | 4 lines Don't crash because of automatic deleting of groups. (BUG: 138834) svn path=/trunk/KDE/kdebase/workspace/; revision=659483
This commit is contained in:
parent
b8ceefc820
commit
23f8ebf2ab
2 changed files with 29 additions and 4 deletions
30
group.cpp
30
group.cpp
|
@ -177,7 +177,8 @@ Group::Group( Window leader_P, Workspace* workspace_P )
|
||||||
leader_wid( leader_P ),
|
leader_wid( leader_P ),
|
||||||
_workspace( workspace_P ),
|
_workspace( workspace_P ),
|
||||||
leader_info( NULL ),
|
leader_info( NULL ),
|
||||||
user_time( -1U )
|
user_time( -1U ),
|
||||||
|
refcount( 0 )
|
||||||
{
|
{
|
||||||
if( leader_P != None )
|
if( leader_P != None )
|
||||||
{
|
{
|
||||||
|
@ -237,7 +238,25 @@ void Group::removeMember( Client* member_P )
|
||||||
// kDebug() << kBacktrace() << endl;
|
// kDebug() << kBacktrace() << endl;
|
||||||
Q_ASSERT( _members.contains( member_P ));
|
Q_ASSERT( _members.contains( member_P ));
|
||||||
_members.removeAll( member_P );
|
_members.removeAll( member_P );
|
||||||
if( _members.isEmpty())
|
// there are cases when automatic deleting of groups must be delayed,
|
||||||
|
// e.g. when removing a member and doing some operation on the possibly
|
||||||
|
// other members of the group (which would be however deleted already
|
||||||
|
// if there were no other members)
|
||||||
|
if( refcount == 0 && _members.isEmpty())
|
||||||
|
{
|
||||||
|
workspace()->removeGroup( this, Allowed );
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Group::ref()
|
||||||
|
{
|
||||||
|
++refcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Group::deref()
|
||||||
|
{
|
||||||
|
if( --refcount == 0 && _members.isEmpty())
|
||||||
{
|
{
|
||||||
workspace()->removeGroup( this, Allowed );
|
workspace()->removeGroup( this, Allowed );
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -914,7 +933,8 @@ void Client::checkGroup( Group* set_group, bool force )
|
||||||
{
|
{
|
||||||
TRANSIENCY_CHECK( this );
|
TRANSIENCY_CHECK( this );
|
||||||
Group* old_group = in_group;
|
Group* old_group = in_group;
|
||||||
Window old_group_leader = old_group != NULL ? old_group->leader() : None;
|
if( old_group != NULL )
|
||||||
|
old_group->ref(); // turn off automatic deleting
|
||||||
if( set_group != NULL )
|
if( set_group != NULL )
|
||||||
{
|
{
|
||||||
if( set_group != in_group )
|
if( set_group != in_group )
|
||||||
|
@ -1003,7 +1023,7 @@ void Client::checkGroup( Group* set_group, bool force )
|
||||||
if( groupTransient())
|
if( groupTransient())
|
||||||
{
|
{
|
||||||
// no longer transient for ones in the old group
|
// no longer transient for ones in the old group
|
||||||
if( old_group != NULL && workspace()->findGroup( old_group_leader ) == old_group ) // if it still exists
|
if( old_group != NULL )
|
||||||
{
|
{
|
||||||
for( ClientList::ConstIterator it = old_group->members().begin();
|
for( ClientList::ConstIterator it = old_group->members().begin();
|
||||||
it != old_group->members().end();
|
it != old_group->members().end();
|
||||||
|
@ -1035,6 +1055,8 @@ void Client::checkGroup( Group* set_group, bool force )
|
||||||
addTransient( *it );
|
addTransient( *it );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( old_group != NULL )
|
||||||
|
old_group->deref(); // can be now deleted if empty
|
||||||
checkGroupTransients();
|
checkGroupTransients();
|
||||||
checkActiveModal();
|
checkActiveModal();
|
||||||
workspace()->updateClientLayer( this );
|
workspace()->updateClientLayer( this );
|
||||||
|
|
3
group.h
3
group.h
|
@ -42,6 +42,8 @@ class Group
|
||||||
bool groupEvent( XEvent* e );
|
bool groupEvent( XEvent* e );
|
||||||
void updateUserTime( Time time = CurrentTime );
|
void updateUserTime( Time time = CurrentTime );
|
||||||
Time userTime() const;
|
Time userTime() const;
|
||||||
|
void ref();
|
||||||
|
void deref();
|
||||||
EffectWindowGroupImpl* effectGroup();
|
EffectWindowGroupImpl* effectGroup();
|
||||||
private:
|
private:
|
||||||
void getIcons();
|
void getIcons();
|
||||||
|
@ -52,6 +54,7 @@ class Group
|
||||||
Workspace* _workspace;
|
Workspace* _workspace;
|
||||||
NETWinInfo* leader_info;
|
NETWinInfo* leader_info;
|
||||||
Time user_time;
|
Time user_time;
|
||||||
|
int refcount;
|
||||||
EffectWindowGroupImpl* effect_group;
|
EffectWindowGroupImpl* effect_group;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue