workspaceThumbnail: Don't keep stale clones in list

If a clone gets destroyed before the corresponding MetaWindow is
removed from the workspace, we will still find it in the list of
clones and try to destroy it again. Avoid the resulting warnings
by updating the list of clones immediately when a clone is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=791233
This commit is contained in:
Florian Müllner 2018-07-09 12:19:00 +02:00
parent d0bdea3178
commit d9a1434ae9

View File

@ -372,15 +372,8 @@ var WorkspaceThumbnail = new Lang.Class({
}, },
_doRemoveWindow(metaWin) { _doRemoveWindow(metaWin) {
// find the position of the window in our list let clone = this._removeWindowClone(metaWin);
let index = this._lookupIndex (metaWin); if (clone)
if (index == -1)
return;
let clone = this._windows[index];
this._windows.splice(index, 1);
clone.destroy(); clone.destroy();
}, },
@ -533,6 +526,9 @@ var WorkspaceThumbnail = new Lang.Class({
clone.connect('drag-end', () => { clone.connect('drag-end', () => {
Main.overview.endWindowDrag(clone.metaWindow); Main.overview.endWindowDrag(clone.metaWindow);
}); });
clone.actor.connect('destroy', () => {
this._removeWindowClone(clone.metaWindow);
});
this._contents.add_actor(clone.actor); this._contents.add_actor(clone.actor);
if (this._windows.length == 0) if (this._windows.length == 0)
@ -545,6 +541,16 @@ var WorkspaceThumbnail = new Lang.Class({
return clone; return clone;
}, },
_removeWindowClone(metaWin) {
// find the position of the window in our list
let index = this._lookupIndex (metaWin);
if (index == -1)
return null;
return this._windows.splice(index, 1).pop();
},
activate(time) { activate(time) {
if (this.state > ThumbnailState.NORMAL) if (this.state > ThumbnailState.NORMAL)
return; return;