[gnome-photos/wip/rishi/collection: 5/47] tracker-controller: React to Source changes only if a Query is active



commit ea5b0e6e6a425350030916719ecd3875f327318a
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Feb 2 03:15:45 2018 +0100

    tracker-controller: React to Source changes only if a Query is active
    
    TrackerControllers with a delayed start might not have issued a Query
    until their respective modes are used. eg., SEARCH. If the Sources
    change before the mode is used, which can happen during startup, the
    TrackerController will queue a refresh even though there isn't a
    current Query. This is a problem because without a current Query it's
    not possible to check if the refresh is actually necessary or not.
    
    So far, this has been working purely by accident because
    TrackerSearchController detects the changes in search criteria before
    Embed. This means that TrackerSearchController is able to slip in a
    Query before Embed switches the mode and causes TrackerController to
    process the queued refresh.
    
    Relying on the order in which signal handlers get invoked is fragile.
    It can change if things are moved around and the order in which they
    are connected to the signal gets altered. It's better to remove the
    possibility of breakage due to such reasons.

 src/photos-tracker-controller.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/photos-tracker-controller.c b/src/photos-tracker-controller.c
index ccf81aba..a8109158 100644
--- a/src/photos-tracker-controller.c
+++ b/src/photos-tracker-controller.c
@@ -382,18 +382,22 @@ static void
 photos_tracker_controller_refresh_for_source (PhotosTrackerController *self)
 {
   PhotosTrackerControllerPrivate *priv;
-  PhotosSource *source;
 
   priv = photos_tracker_controller_get_instance_private (self);
 
-  source = photos_query_get_source (priv->current_query);
-  if (source != NULL)
+  if (priv->current_query != NULL)
     {
-      const gchar *id;
+      PhotosSource *source;
 
-      id = photos_filterable_get_id (PHOTOS_FILTERABLE (source));
-      if (g_strcmp0 (id, PHOTOS_SOURCE_STOCK_ALL) == 0)
-        photos_tracker_controller_refresh_internal (self, PHOTOS_TRACKER_REFRESH_FLAGS_NONE);
+      source = photos_query_get_source (priv->current_query);
+      if (source != NULL)
+        {
+          const gchar *id;
+
+          id = photos_filterable_get_id (PHOTOS_FILTERABLE (source));
+          if (g_strcmp0 (id, PHOTOS_SOURCE_STOCK_ALL) == 0)
+            photos_tracker_controller_refresh_internal (self, PHOTOS_TRACKER_REFRESH_FLAGS_NONE);
+        }
     }
 
   priv->refresh_pending = FALSE;


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