[gnome-documents/wip/rishi/init-getting-started: 7/9] trackerController: Assert against premature queries

commit 7dd0bdc4ab7a11abbaf06ad8a7557bba00dbade6
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Dec 8 20:47:17 2017 +0100

    trackerController: Assert against premature queries
    The TrackerControllers are only supposed to issue their queries once
    all the pieces of the application that are necessary to formulate them
    have been initialized. This is indicated by the invocation of the start
    method. For example, if the queries are submitted before the detection
    of the getting started PDF has completed, then they won't have the
    path to PDF and it will be missing from the UI.
    Throwing an exception forces one to think about the details surrounding
    each query submission path, as opposed to having the silently dropping
    the request.

 src/trackerController.js |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/trackerController.js b/src/trackerController.js
index 55f1343..e45f3a7 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -234,7 +234,8 @@ const TrackerController = new Lang.Class({
     _refreshInternal: function(flags) {
-        this._isStarted = true;
+        if (!this._isStarted)
+            throw(new Error('!this._isStarted'));
         if (flags & RefreshFlags.RESET_OFFSET)
@@ -294,6 +295,7 @@ const TrackerController = new Lang.Class({
         if (this._isStarted)
+        this._isStarted = true;

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