[gnome-documents] selections: don't crash when a job is run with no callback



commit 102be2131829a73dae35069f64bad092538f02d3
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Mar 8 13:22:02 2012 -0500

    selections: don't crash when a job is run with no callback
    
    Sometimes we might want to do this for some jobs.

 src/selections.js |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/selections.js b/src/selections.js
index 370135c..f1f292e 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -90,7 +90,8 @@ FetchCollectionsJob.prototype = {
     },
 
     _emitCallback: function() {
-        this._callback(this._collections);
+        if (this._callback)
+            this._callback(this._collections);
     }
 };
 
@@ -186,7 +187,8 @@ FetchCollectionStateForSelectionJob.prototype = {
             collectionState[collIdx] = state;
         }
 
-        this._callback(collectionState);
+        if (this._callback)
+            this._callback(collectionState);
     }
 };
 
@@ -212,7 +214,8 @@ UpdateMtimeJob.prototype = {
                     log(e);
                 }
 
-                this._callback();
+                if (this._callback)
+                    this._callback();
             }));
     }
 };
@@ -263,7 +266,9 @@ SetCollectionForSelectionJob.prototype = {
             let job = new UpdateMtimeJob(this._collectionUrn);
             job.run(Lang.bind(this,
                 function() {
-                    this._callback();
+
+                    if (this._callback)
+                        this._callback();
                 }));
         }
     }



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