background: properly disconnect background signals
BackgroundManager connects to the changed signal in the backgrounds it manages. The signal ids for the changed signal connectionss are stored as state on the background manager object. If the background being managed changes while the manager is still loading the old background, then the signal id variable can get out of sync with the background object being managed. This commit ties the signal id to the background objects themselves, so there is no opportunity for them to desynchronize. https://bugzilla.gnome.org/show_bug.cgi?id=696157
This commit is contained in:
parent
b9da6d9ef6
commit
f920fd8b6f
@ -654,17 +654,9 @@ const BackgroundManager = new Lang.Class({
|
||||
|
||||
this.background = this._createBackground();
|
||||
this._newBackground = null;
|
||||
this._loadedSignalId = 0;
|
||||
this._changedSignalId = 0;
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if (this._loadedSignalId)
|
||||
this._newBackground.disconnect(this._loadedSignalId);
|
||||
|
||||
if (this._changedSignalId)
|
||||
this.background.disconnect(this._changedSignalId);
|
||||
|
||||
if (this._newBackground) {
|
||||
this._newBackground.actor.destroy();
|
||||
this._newBackground = null;
|
||||
@ -683,22 +675,24 @@ const BackgroundManager = new Lang.Class({
|
||||
newBackground.saturation = background.saturation;
|
||||
newBackground.visible = background.visible;
|
||||
|
||||
let signalId = newBackground.connect('loaded',
|
||||
newBackground.loadedSignalId = newBackground.connect('loaded',
|
||||
Lang.bind(this, function() {
|
||||
newBackground.disconnect(signalId);
|
||||
newBackground.disconnect(newBackground.loadedSignalId);
|
||||
newBackground.loadedSignalId = 0;
|
||||
Tweener.addTween(background.actor,
|
||||
{ opacity: 0,
|
||||
time: FADE_ANIMATION_TIME,
|
||||
transition: 'easeOutQuad',
|
||||
onComplete: Lang.bind(this, function() {
|
||||
if (this.background == background) {
|
||||
this.background = newBackground;
|
||||
this._newBackground = null;
|
||||
background.actor.destroy();
|
||||
}
|
||||
this.emit('changed');
|
||||
})
|
||||
});
|
||||
}));
|
||||
this._loadedSignalId = signalId;
|
||||
|
||||
this._newBackground = newBackground;
|
||||
},
|
||||
@ -717,12 +711,19 @@ const BackgroundManager = new Lang.Class({
|
||||
background.actor.lower_bottom();
|
||||
}
|
||||
|
||||
let signalId = background.connect('changed', Lang.bind(this, function() {
|
||||
background.disconnect(signalId);
|
||||
background.changeSignalId = background.connect('changed', Lang.bind(this, function() {
|
||||
background.disconnect(background.changeSignalId);
|
||||
background.changeSignalId = 0;
|
||||
this._updateBackground(background, this._monitorIndex);
|
||||
}));
|
||||
|
||||
this._changedSignalId = signalId;
|
||||
background.actor.connect('destroy', Lang.bind(this, function() {
|
||||
if (background.changeSignalId)
|
||||
background.disconnect(background.changeSignalId);
|
||||
|
||||
if (background.loadedSignalId)
|
||||
background.disconnect(background.loadedSignalId);
|
||||
}));
|
||||
|
||||
return background;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user