[gnome-photos] application: Remove any future timeouts before refreshing a miner



commit deeb9fe6933660f2f5a8b7ffc7c474e42c8c0f1c
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jul 14 00:08:43 2016 +0200

    application: Remove any future timeouts before refreshing a miner
    
    We call RefreshDB on the miners at certain times:
     - at startup
     - at 1 minute intervals thereafter
     - when there is a change in the available Sources
    
    In the last case, we might end up calling RefreshDB when it has also
    been scheduled to run at some point in the future. This violates an
    assertion in photos_application_refresh_db that protects against it.
    Since a change in the available Sources indicates an explicit user
    action, it will be nice to immediately react to it. Let's remove the
    timeout and then do so.

 src/photos-application.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 5e40da6..ddc5852 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -965,6 +965,7 @@ photos_application_refresh_miner_now (PhotosApplication *self, GomMiner *miner)
 {
   GCancellable *cancellable;
   const gchar *const index_types[] = {"photos", NULL};
+  gpointer refresh_miner_id_data;
 
   if (g_getenv ("GNOME_PHOTOS_DISABLE_MINERS") != NULL)
     return;
@@ -972,6 +973,15 @@ photos_application_refresh_miner_now (PhotosApplication *self, GomMiner *miner)
   if (g_list_find (self->miners_running, miner) != NULL)
     return;
 
+  refresh_miner_id_data = g_hash_table_lookup (self->refresh_miner_ids, miner);
+  if (refresh_miner_id_data != NULL)
+    {
+      guint refresh_miner_id = GPOINTER_TO_UINT (refresh_miner_id_data);
+
+      g_source_remove (refresh_miner_id);
+      g_hash_table_remove (self->refresh_miner_ids, miner);
+    }
+
   self->miners_running = g_list_prepend (self->miners_running, g_object_ref (miner));
   g_signal_emit (self, signals[MINERS_CHANGED], 0, self->miners_running);
 


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