[gnome-shell] background: refactor file loading



commit e917b7ce0f1dca31683534e1980477b0b88da0de
Author: Ray Strode <rstrode redhat com>
Date:   Wed Feb 26 15:13:21 2014 -0500

    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

 js/ui/background.js |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/background.js b/js/ui/background.js
index 3fe279d..396309a 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -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 });
 
+        let caller = { monitorIndex: params.monitorIndex,
+                       effects: params.effects,
+                       onFinished: params.onFinished };
+
         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,
-                                                         effects: params.effects,
-                                                         onFinished: params.onFinished });
+            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,
-                                      style: params.style,
-                                      callers: [{ monitorIndex: params.monitorIndex,
-                                                  effects: params.effects,
-                                                  onFinished: params.onFinished }] });
+        let fileLoad = { filename: params.filename,
+                         style: params.style,
+                         callers: [] };
+        this._attachCallerToFileLoad(caller, fileLoad);
 
         let content = new Meta.Background({ meta_screen: global.screen });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]