[gnome-builder] egg-task-cache: assertions and cast cleanup



commit 9666e7b2d22cfc7340a3ce9480a0703aaecbc82f
Author: Christian Hergert <chergert redhat com>
Date:   Mon Mar 6 14:22:59 2017 -0800

    egg-task-cache: assertions and cast cleanup
    
    Be extra careful so we can catch bugs early with assertions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779660

 contrib/egg/egg-task-cache.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/contrib/egg/egg-task-cache.c b/contrib/egg/egg-task-cache.c
index 3a9f602..45e9909 100644
--- a/contrib/egg/egg-task-cache.c
+++ b/contrib/egg/egg-task-cache.c
@@ -475,11 +475,19 @@ egg_task_cache_cancelled_cb (GCancellable *cancellable,
   EggTaskCache *self;
   CancelledData *data;
   GPtrArray *queued;
-  GTask *task = (GTask *)user_data;
+  GTask *task = user_data;
   gboolean cancelled = FALSE;
 
-  self = (EggTaskCache *)g_task_get_source_object (task);
-  data = (CancelledData *)g_task_get_task_data (task);
+  g_assert (G_IS_CANCELLABLE (cancellable));
+  g_assert (G_IS_TASK (task));
+
+  self = g_task_get_source_object (task);
+  data = g_task_get_task_data (task);
+
+  g_assert (EGG_IS_TASK_CACHE (self));
+  g_assert (data != NULL);
+  g_assert (data->self == self);
+  g_assert (!data->cancellable || G_IS_CANCELLABLE (data->cancellable));
 
   data->cancelled_id = 0;
 


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