[grilo] core: Notify when an operation is performed over invalid operation_id



commit f3917fa0a40ce257874947c38a42a49685c0b656
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Wed Dec 5 17:27:34 2012 +0000

    core: Notify when an operation is performed over invalid operation_id
    
    It is actually done, but no message is actually shown to developer.

 src/grl-operation.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/grl-operation.c b/src/grl-operation.c
index 05837cb..222998d 100644
--- a/src/grl-operation.c
+++ b/src/grl-operation.c
@@ -22,6 +22,7 @@
 
 #include "grl-operation.h"
 #include "grl-operation-priv.h"
+#include "grl-log.h"
 
 typedef struct
 {
@@ -121,6 +122,11 @@ grl_operation_cancel (guint operation_id)
   OperationData *data = g_hash_table_lookup (operations,
                                              GUINT_TO_POINTER (operation_id));
 
+  if (!data) {
+    GRL_WARNING ("Invalid operation %u", operation_id);
+    return;
+  }
+
   g_return_if_fail (data != NULL);
 
   if (data->cancel_cb) {
@@ -142,7 +148,10 @@ grl_operation_get_data (guint operation_id)
   OperationData *data = g_hash_table_lookup (operations,
                                              GUINT_TO_POINTER (operation_id));
 
-  g_return_val_if_fail (data != NULL, NULL);
+  if (!data) {
+    GRL_WARNING ("Invalid operation %u", operation_id);
+    return NULL;
+  }
 
   return data->user_data;
 }
@@ -160,8 +169,10 @@ grl_operation_set_data (guint operation_id, gpointer user_data)
   OperationData *data = g_hash_table_lookup (operations,
                                              GUINT_TO_POINTER (operation_id));
 
-  g_return_if_fail (data != NULL);
-
-  data->user_data = user_data;
+  if (!data) {
+    GRL_WARNING ("Invalid operation %u", operation_id);
+  } else {
+    data->user_data = user_data;
+  }
 }
 



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