From 5262a4161993e50d046a0c770b52413ac9c36015 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 3 Dec 2013 18:08:42 -0500 Subject: [PATCH] background: Clarify the intent of the code Stomping on local variables and trying to keep loop state isn't too fun. Just use a new variable here so we aren't too confused with what we're doing. https://bugzilla.gnome.org/show_bug.cgi?id=719803 --- js/ui/background.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/ui/background.js b/js/ui/background.js index 79e58a7f0..1d9f55c8a 100644 --- a/js/ui/background.js +++ b/js/ui/background.js @@ -183,13 +183,16 @@ const BackgroundCache = new Lang.Class({ for (let j = 0; j < pendingLoad.callers.length; j++) { if (pendingLoad.callers[j].onFinished) { - if (content && pendingLoad.callers[j].shouldCopy) { - content = object.copy(pendingLoad.callers[j].monitorIndex, - pendingLoad.callers[j].effects); + let newContent; + if (content && pendingLoad.callers[j].shouldCopy) { + newContent = content.copy(pendingLoad.callers[j].monitorIndex, + pendingLoad.callers[j].effects); + } else { + newContent = content; } - pendingLoad.callers[j].onFinished(content); + pendingLoad.callers[j].onFinished(newContent); } }