Revert "background: fix asynchronous management of background loading operations"
This reverts commit 1020d8a0f8523a04d8336b1348388b8b242e414f. https://bugzilla.gnome.org/show_bug.cgi?id=704646
This commit is contained in:
parent
945b357ed8
commit
062235f3a7
@ -142,20 +142,23 @@ const BackgroundCache = new Lang.Class({
|
|||||||
cancellable: null,
|
cancellable: null,
|
||||||
onFinished: null });
|
onFinished: null });
|
||||||
|
|
||||||
let fileLoad = { filename: params.filename,
|
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
||||||
style: params.style,
|
if (this._pendingFileLoads[i].filename == params.filename &&
|
||||||
shouldCopy: false,
|
this._pendingFileLoads[i].style == params.style) {
|
||||||
|
this._pendingFileLoads[i].callers.push({ shouldCopy: true,
|
||||||
monitorIndex: params.monitorIndex,
|
monitorIndex: params.monitorIndex,
|
||||||
effects: params.effects,
|
effects: params.effects,
|
||||||
onFinished: params.onFinished,
|
onFinished: params.onFinished });
|
||||||
cancellable: new Gio.Cancellable(), };
|
return;
|
||||||
this._pendingFileLoads.push(fileLoad);
|
|
||||||
|
|
||||||
if (params.cancellable) {
|
|
||||||
params.cancellable.connect(Lang.bind(this, function(c) {
|
|
||||||
fileLoad.cancellable.cancel();
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._pendingFileLoads.push({ filename: params.filename,
|
||||||
|
style: params.style,
|
||||||
|
callers: [{ shouldCopy: false,
|
||||||
|
monitorIndex: params.monitorIndex,
|
||||||
|
effects: params.effects,
|
||||||
|
onFinished: params.onFinished }] });
|
||||||
|
|
||||||
let content = new Meta.Background({ meta_screen: global.screen,
|
let content = new Meta.Background({ meta_screen: global.screen,
|
||||||
monitor: params.monitorIndex,
|
monitor: params.monitorIndex,
|
||||||
@ -163,19 +166,9 @@ const BackgroundCache = new Lang.Class({
|
|||||||
|
|
||||||
content.load_file_async(params.filename,
|
content.load_file_async(params.filename,
|
||||||
params.style,
|
params.style,
|
||||||
fileLoad.cancellable,
|
params.cancellable,
|
||||||
Lang.bind(this,
|
Lang.bind(this,
|
||||||
function(object, result) {
|
function(object, result) {
|
||||||
if (fileLoad.cancellable.is_cancelled()) {
|
|
||||||
if (params.cancellable && params.cancellable.is_cancelled()) {
|
|
||||||
if (params.onFinished)
|
|
||||||
params.onFinished(null);
|
|
||||||
this._removePendingFileLoad(fileLoad);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
content.load_file_finish(result);
|
content.load_file_finish(result);
|
||||||
|
|
||||||
@ -185,25 +178,22 @@ const BackgroundCache = new Lang.Class({
|
|||||||
content = null;
|
content = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let needsCopy = false;
|
|
||||||
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
||||||
let pendingLoad = this._pendingFileLoads[i];
|
let pendingLoad = this._pendingFileLoads[i];
|
||||||
if (pendingLoad.filename != params.filename ||
|
if (pendingLoad.filename != params.filename ||
|
||||||
pendingLoad.style != params.style)
|
pendingLoad.style != params.style)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (pendingLoad.cancellable.is_cancelled())
|
for (let j = 0; j < pendingLoad.callers.length; j++) {
|
||||||
continue;
|
if (pendingLoad.callers[j].onFinished) {
|
||||||
|
if (content && pendingLoad.callers[j].shouldCopy) {
|
||||||
|
content = object.copy(pendingLoad.callers[j].monitorIndex,
|
||||||
|
pendingLoad.callers[j].effects);
|
||||||
|
|
||||||
pendingLoad.cancellable.cancel();
|
|
||||||
if (pendingLoad.onFinished) {
|
|
||||||
if (content && needsCopy) {
|
|
||||||
content = object.copy(pendingLoad.monitorIndex,
|
|
||||||
pendingLoad.effects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
needsCopy = true;
|
pendingLoad.callers[j].onFinished(content);
|
||||||
pendingLoad.onFinished(content);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._pendingFileLoads.splice(i, 1);
|
this._pendingFileLoads.splice(i, 1);
|
||||||
@ -211,15 +201,6 @@ const BackgroundCache = new Lang.Class({
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_removePendingFileLoad: function(fileLoad) {
|
|
||||||
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
|
||||||
if (this._pendingFileLoads[i].cancellable == fileLoad.cancellable) {
|
|
||||||
this._pendingFileLoads.splice(i, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getImageContent: function(params) {
|
getImageContent: function(params) {
|
||||||
params = Params.parse(params, { monitorIndex: 0,
|
params = Params.parse(params, { monitorIndex: 0,
|
||||||
style: null,
|
style: null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user