[anjuta/sdb-queries] symbol-db: Fixed async query signal, Fixed warnings.



commit e121e74a6bf35e7e9ae5544d6054e56cba0c8c1a
Author: Naba Kumar <naba gnome org>
Date:   Sun Jun 13 16:49:44 2010 +0300

    symbol-db: Fixed async query signal, Fixed warnings.

 plugins/symbol-db/symbol-db-query-result.c |    8 ++--
 plugins/symbol-db/symbol-db-query.c        |   49 ++++++++++++++++-----------
 2 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/plugins/symbol-db/symbol-db-query-result.c b/plugins/symbol-db/symbol-db-query-result.c
index b57fb96..3b62f4e 100644
--- a/plugins/symbol-db/symbol-db-query-result.c
+++ b/plugins/symbol-db/symbol-db-query-result.c
@@ -85,9 +85,9 @@ sdb_query_result_validate_field (SymbolDBQueryResult *result,
 	{
 		g_set_error (err, SYMBOL_DB_QUERY_RESULT_ERROR,
 		             SYMBOL_DB_QUERY_RESULT_ERROR_FIELD_NOT_PRESENT,
-		             "Symbol field '%' is present in the query. Make sure to "
+		             "Symbol field '%d' is present in the query. Make sure to "
 		             "include the during query creation.", field);
-		g_warning ("Symbol field '%' is present in the query. Make sure to "
+		g_warning ("Symbol field '%d' is present in the query. Make sure to "
 		             "include the during query creation.", field);
 		return FALSE;
 	}
@@ -300,7 +300,6 @@ isymbol_get_int (IAnjutaSymbol *isymbol, IAnjutaSymbolField field,
 		gint type_val = 
 			(gint)g_hash_table_lookup ((GHashTable*)result->priv->sym_type_conversion_hash, 
 			                           type_str);
-		DEBUG_PRINT ("Type str = %s = %d", type_str, type_val);
 		return type_val;
 	}
 	return g_value_get_int (val);
@@ -322,7 +321,8 @@ isymbol_get_string (IAnjutaSymbol *isymbol, IAnjutaSymbolField field,
 	col = result->priv->col_map[field];
 	val = gda_data_model_iter_get_value_at (result->priv->iter, col);
 	if (!val) return NULL;
-	return (const gchar*) g_value_get_string (val);
+	if (!G_VALUE_HOLDS_STRING (val)) return NULL;
+	return g_value_get_string (val);
 }
 
 static IAnjutaSymbolType 
diff --git a/plugins/symbol-db/symbol-db-query.c b/plugins/symbol-db/symbol-db-query.c
index 43681f6..4a2ed66 100644
--- a/plugins/symbol-db/symbol-db-query.c
+++ b/plugins/symbol-db/symbol-db-query.c
@@ -67,8 +67,8 @@ struct _SymbolDBQueryPriv {
 	GdaHolder *param_file_line, *param_id;
 
 	/* Aync results */
-	gint async_count;
-	gint cancel_count;
+	gint pending_async_count;
+	gint pending_cancel_count;
 	gboolean query_queued;
 	IAnjutaIterable *async_result;
 };
@@ -336,7 +336,7 @@ sdb_query_update (SymbolDBQuery *query)
 					SELECT symbol.scope_id \
 					FROM symbol \
 					WHERE symbol.symbol_id = ## /* name:'symbolid' type:gint */ \
-				) ";
+				)) ";
 			g_object_set (query, "limit", 1, NULL);
 			break;
 		case IANJUTA_SYMBOL_QUERY_SEARCH_PARENT_SCOPE_FILE:
@@ -346,7 +346,7 @@ sdb_query_update (SymbolDBQuery *query)
 					SELECT symbol.scope_id \
 					FROM symbol \
 					WHERE symbol.symbol_id = ## /* name:'symbolid' type:gint */ \
-				) AND file.file_path = ## /* name:'filepath' type:gchararray */ ";
+				) AND file.file_path = ## /* name:'filepath' type:gchararray */) ";
 			sdb_query_add_field (query, IANJUTA_SYMBOL_FIELD_FILE_PATH);
 			g_object_set (query, "limit", 1, NULL);
 			break;
@@ -417,12 +417,18 @@ sdb_query_execute_real (SymbolDBQuery *query)
 static void
 on_sdb_query_async_data_arrived (SymbolDBQuery *query, gpointer data)
 {
-	query->priv->async_count++;
-	if (query->priv->async_count > query->priv->cancel_count)
+	query->priv->pending_async_count--;
+	if (query->priv->pending_cancel_count <= 0)
 		g_signal_emit_by_name (query, "async-result",
 		                       query->priv->async_result);
-	g_object_unref (query->priv->async_result);
-	query->priv->async_result = NULL;
+	else
+		query->priv->pending_cancel_count--;
+	
+	if (query->priv->async_result)
+	{
+		g_object_unref (query->priv->async_result);
+		query->priv->async_result = NULL;
+	}
 }
 
 static guint
@@ -436,6 +442,7 @@ sdb_query_async_run (AnjutaCommand *command)
 	g_return_val_if_fail (query->priv->mode == IANJUTA_SYMBOL_QUERY_MODE_ASYNC, -1);
 	
 	query->priv->async_result = sdb_query_execute_real (query);
+	anjuta_command_notify_data_arrived (command);
 	return 0;
 }
 
@@ -447,7 +454,7 @@ sdb_query_async_cancel (AnjutaCommand *command)
 	query = SYMBOL_DB_QUERY (command);
 
 	g_return_if_fail (query->priv->mode != IANJUTA_SYMBOL_QUERY_MODE_SYNC);
-	query->priv->cancel_count++;
+	query->priv->pending_cancel_count = query->priv->pending_async_count;
 	query->priv->query_queued = FALSE;
 }
 
@@ -495,6 +502,7 @@ sdb_query_execute (SymbolDBQuery *query)
 		case IANJUTA_SYMBOL_QUERY_MODE_SYNC:
 			return sdb_query_execute_real (query);
 		case IANJUTA_SYMBOL_QUERY_MODE_ASYNC:
+			query->priv->pending_async_count++;
 			anjuta_command_start (ANJUTA_COMMAND (query));
 			return NULL;
 		case IANJUTA_SYMBOL_QUERY_MODE_QUEUED_SINGLE:
@@ -546,8 +554,8 @@ sdb_query_init (SymbolDBQuery *query)
 	g_slist_free (param_holders);
 
 	/* Prepare async signals */
-	priv->async_count = 0;
-	priv->cancel_count = 0;
+	priv->pending_async_count = 0;
+	priv->pending_cancel_count = 0;
 	priv->async_result = NULL;
 	priv->query_queued = FALSE;
 	g_signal_connect (query, "data-arrived",
@@ -632,7 +640,7 @@ sdb_query_set_property (GObject *object, guint prop_id, const GValue *value, GPa
 		priv->mode = g_value_get_enum (value);
 		break;
 	case PROP_FILTERS:
-		priv->filters = g_value_get_enum (value);
+		priv->filters = g_value_get_int (value);
 		sdb_query_update (query);
 		break;
 	case PROP_FILE_SCOPE:
@@ -697,7 +705,7 @@ sdb_query_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
 		g_value_set_enum (value, priv->mode);
 		break;
 	case PROP_FILTERS:
-		g_value_set_enum (value, priv->filters);
+		g_value_set_int (value, priv->filters);
 		break;
 	case PROP_FILE_SCOPE:
 		g_value_set_enum (value, priv->file_scope);
@@ -772,13 +780,14 @@ sdb_query_class_init (SymbolDBQueryClass *klass)
 	                                                    G_PARAM_WRITABLE));
 	g_object_class_install_property (object_class,
 	                                 PROP_FILTERS,
-	                                 g_param_spec_enum ("filters",
-	                                                    "Symbol type filters",
-	                                                    "The symbol type filters",
-	                                                    IANJUTA_TYPE_SYMBOL_TYPE,
-	                                                    IANJUTA_SYMBOL_TYPE_NONE,
-	                                                    G_PARAM_READABLE |
-	                                                    G_PARAM_WRITABLE));
+	                                 g_param_spec_int ("filters",
+	                                                   "Symbol type filters",
+	                                                   "The symbol type filters",
+	                                                   IANJUTA_SYMBOL_TYPE_NONE,
+	                                                   IANJUTA_SYMBOL_TYPE_MAX,
+	                                                   IANJUTA_SYMBOL_TYPE_NONE,
+	                                                   G_PARAM_READABLE |
+	                                                   G_PARAM_WRITABLE));
 	g_object_class_install_property (object_class,
 	                                 PROP_FILE_SCOPE,
 	                                 g_param_spec_enum ("file-scope",



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