background: refactor file loading
This commit moves the code around a bit such that the caller gets allocated up front and then a file load is either found or created to attach the caller to. Functionally, the code is the same, it's just now factored in a way that will make it easier to fix a bug with cancellation later. https://bugzilla.gnome.org/show_bug.cgi?id=722149
This commit is contained in:
parent
ec6facb9e7
commit
e917b7ce0f
@ -132,6 +132,10 @@ const BackgroundCache = new Lang.Class({
|
||||
this._removeContent(this._images, content);
|
||||
},
|
||||
|
||||
_attachCallerToFileLoad: function(caller, fileLoad) {
|
||||
fileLoad.callers.push(caller);
|
||||
},
|
||||
|
||||
_loadImageContent: function(params) {
|
||||
params = Params.parse(params, { monitorIndex: 0,
|
||||
style: null,
|
||||
@ -140,21 +144,24 @@ const BackgroundCache = new Lang.Class({
|
||||
cancellable: null,
|
||||
onFinished: null });
|
||||
|
||||
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
||||
if (this._pendingFileLoads[i].filename == params.filename &&
|
||||
this._pendingFileLoads[i].style == params.style) {
|
||||
this._pendingFileLoads[i].callers.push({ monitorIndex: params.monitorIndex,
|
||||
let caller = { monitorIndex: params.monitorIndex,
|
||||
effects: params.effects,
|
||||
onFinished: params.onFinished });
|
||||
onFinished: params.onFinished };
|
||||
|
||||
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
||||
let fileLoad = this._pendingFileLoads[i];
|
||||
|
||||
if (fileLoad.filename == params.filename &&
|
||||
fileLoad.style == params.style) {
|
||||
this._attachCallerToFileLoad(caller, fileLoad);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this._pendingFileLoads.push({ filename: params.filename,
|
||||
let fileLoad = { filename: params.filename,
|
||||
style: params.style,
|
||||
callers: [{ monitorIndex: params.monitorIndex,
|
||||
effects: params.effects,
|
||||
onFinished: params.onFinished }] });
|
||||
callers: [] };
|
||||
this._attachCallerToFileLoad(caller, fileLoad);
|
||||
|
||||
let content = new Meta.Background({ meta_screen: global.screen });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user