workspaceThumbnail: disconnect handlers when workspace is removed

We need to remove the handlers when the workspace is removed, not
when the animation of it being removed finishes, or we can access
a destroyed workspace and triggger an assertion failure in Mutter.

https://bugzilla.redhat.com/show_bug.cgi?id=705664
https://bugzilla.gnome.org/show_bug.cgi?id=667652
This commit is contained in:
Owen W. Taylor 2012-01-11 17:24:42 -05:00
parent fa515328eb
commit d9ab2320d5

View File

@ -148,6 +148,8 @@ WorkspaceThumbnail.prototype = {
this.metaWorkspace = metaWorkspace; this.metaWorkspace = metaWorkspace;
this.monitorIndex = Main.layoutManager.primaryIndex; this.monitorIndex = Main.layoutManager.primaryIndex;
this._removed = false;
this.actor = new St.Group({ reactive: true, this.actor = new St.Group({ reactive: true,
clip_to_allocation: true, clip_to_allocation: true,
style_class: 'workspace-thumbnail' }); style_class: 'workspace-thumbnail' });
@ -278,7 +280,7 @@ WorkspaceThumbnail.prototype = {
}, },
_doAddWindow : function(metaWin) { _doAddWindow : function(metaWin) {
if (this.leavingOverview) if (this._removed)
return; return;
let win = metaWin.get_compositor_private(); let win = metaWin.get_compositor_private();
@ -288,7 +290,7 @@ WorkspaceThumbnail.prototype = {
// the compositor finds out about them... // the compositor finds out about them...
Mainloop.idle_add(Lang.bind(this, Mainloop.idle_add(Lang.bind(this,
function () { function () {
if (this.actor && if (!this._removed &&
metaWin.get_compositor_private() && metaWin.get_compositor_private() &&
metaWin.get_workspace() == this.metaWorkspace) metaWin.get_workspace() == this.metaWorkspace)
this._doAddWindow(metaWin); this._doAddWindow(metaWin);
@ -344,7 +346,12 @@ WorkspaceThumbnail.prototype = {
this.actor.destroy(); this.actor.destroy();
}, },
_onDestroy: function(actor) { workspaceRemoved : function() {
if (this._removed)
return;
this._removed = true;
this.metaWorkspace.disconnect(this._windowAddedId); this.metaWorkspace.disconnect(this._windowAddedId);
this.metaWorkspace.disconnect(this._windowRemovedId); this.metaWorkspace.disconnect(this._windowRemovedId);
global.screen.disconnect(this._windowEnteredMonitorId); global.screen.disconnect(this._windowEnteredMonitorId);
@ -357,6 +364,10 @@ WorkspaceThumbnail.prototype = {
delete metaWin._minimizedChangedId; delete metaWin._minimizedChangedId;
} }
} }
},
_onDestroy: function(actor) {
this.workspaceRemoved();
this._windows = []; this._windows = [];
this.actor = null; this.actor = null;
@ -584,6 +595,8 @@ ThumbnailsBox.prototype = {
if (thumbnail.state > ThumbnailState.NORMAL) if (thumbnail.state > ThumbnailState.NORMAL)
continue; continue;
thumbnail.workspaceRemoved();
if (currentPos >= start && currentPos < start + count) if (currentPos >= start && currentPos < start + count)
this._setThumbnailState(thumbnail, ThumbnailState.REMOVING); this._setThumbnailState(thumbnail, ThumbnailState.REMOVING);