[anjuta/sdb-core-trans: 10/14] symbol-db: Make queued query work. Make class inheritance use queued query.



commit ebc6167a127024f2a6d99285e4a031a2bf695397
Author: Naba Kumar <naba gnome org>
Date:   Sun Jun 20 00:58:31 2010 +0300

    symbol-db: Make queued query work. Make class inheritance use queued query.

 plugins/class-inheritance/class-inherit.c |   52 +++++++++++++++++++----------
 plugins/symbol-db/symbol-db-query.c       |   14 +++++--
 2 files changed, 44 insertions(+), 22 deletions(-)
---
diff --git a/plugins/class-inheritance/class-inherit.c b/plugins/class-inheritance/class-inherit.c
index 65cb7ff..e704175 100644
--- a/plugins/class-inheritance/class-inherit.c
+++ b/plugins/class-inheritance/class-inherit.c
@@ -963,6 +963,13 @@ on_cls_node_delete_marked (gpointer key, ClsNode *cls_node, gpointer data)
 	return TRUE;
 }
 
+static gboolean
+on_cls_node_delete (gpointer key, ClsNode *cls_node, gpointer data)
+{
+	cls_node_unlink (cls_node);
+	return TRUE;
+}
+
 /*----------------------------------------------------------------------------
  * update the internal graphviz graph-structure, then redraw the graph on the 
  * canvas
@@ -970,29 +977,35 @@ on_cls_node_delete_marked (gpointer key, ClsNode *cls_node, gpointer data)
 void
 cls_inherit_update (AnjutaClassInheritance *plugin)
 {
-	IAnjutaIterable *iter;
+	g_return_if_fail (plugin != NULL);
+
+	if (plugin->top_dir == NULL)
+	{
+		/* No project, delete all nodes */
+		g_hash_table_foreach_remove (plugin->nodes,
+		                             (GHRFunc) on_cls_node_delete,
+		                             NULL);
+		cls_inherit_draw (plugin);
+	}
+	else
+	{
+		/* Get all classes */
+		ianjuta_symbol_query_search_all (plugin->query_project, NULL);
+	}
+}
+
+static void
+on_cls_inherit_update (IAnjutaSymbolQuery *query, IAnjutaIterable *iter,
+                       AnjutaClassInheritance *plugin)
+{
 	IAnjutaSymbol *symbol;
 	ClsNode *cls_node;
 	GError *err = NULL;
-
-	g_return_if_fail (plugin != NULL);
-
+	
 	/* Mark all nodes for deletion. Selectively, they will be unmarked below */
 	g_hash_table_foreach (plugin->nodes,
 	                      (GHFunc) on_cls_node_mark_for_deletion,
 	                      NULL);
-
-	if (plugin->top_dir == NULL)
-		goto cleanup;
-	
-	/* Get all classes */
-	iter = ianjuta_symbol_query_search_all (plugin->query_project, &err);
-	if (err)
-	{
-		g_warning ("Classes query in project failed: %s", err->message);
-		g_error_free (err);
-		err = NULL;
-	}
 	if (!iter)
 	{
 		DEBUG_PRINT ("%s", "cls_inherit_update_graph (): search returned no items.");
@@ -1074,8 +1087,6 @@ cls_inherit_update (AnjutaClassInheritance *plugin)
 
 	} while (ianjuta_iterable_next (iter, NULL) == TRUE);
 
-	g_object_unref (iter);
-
 cleanup:
 	
 	/* Delete all marked nodes that did not get unmarked above. */
@@ -1221,6 +1232,11 @@ cls_inherit_init (AnjutaClassInheritance *plugin)
 		                                     IANJUTA_SYMBOL_QUERY_SEARCH_ALL,
 		                                     IANJUTA_SYMBOL_QUERY_DB_PROJECT,
 		                                     NULL);
+	g_signal_connect (plugin->query_project, "async-result",
+	                  G_CALLBACK (on_cls_inherit_update), plugin);
+	ianjuta_symbol_query_set_mode (plugin->query_project,
+	                               IANJUTA_SYMBOL_QUERY_MODE_QUEUED,
+	                               NULL);
 	ianjuta_symbol_query_set_fields (plugin->query_project,
 	                                 sizeof (query_fields_simple)/sizeof (IAnjutaSymbolField),
 	                                 query_fields_simple, NULL);
diff --git a/plugins/symbol-db/symbol-db-query.c b/plugins/symbol-db/symbol-db-query.c
index a37dfc1..a00ae0f 100644
--- a/plugins/symbol-db/symbol-db-query.c
+++ b/plugins/symbol-db/symbol-db-query.c
@@ -494,8 +494,12 @@ sdb_query_execute_real (SymbolDBQuery *query)
 	GdaDataModel *data_model;
 	SymbolDBQueryPriv *priv = query->priv;
 
-	if (!symbol_db_engine_is_connected (priv->dbe_selected) ||
-	    symbol_db_engine_is_scanning (priv->dbe_selected))
+	if (!symbol_db_engine_is_connected (priv->dbe_selected))
+	{
+		g_warning ("Attempt to make a query when database is not connected");
+		return GINT_TO_POINTER (-1);
+	}
+	if (symbol_db_engine_is_scanning (priv->dbe_selected))
 		return GINT_TO_POINTER (-1);
 	
 	if (!priv->sql_stmt)
@@ -517,7 +521,10 @@ static void
 sdb_query_handle_result (SymbolDBQuery *query, SymbolDBQueryResult *result)
 {
 	if (GPOINTER_TO_INT (result) == -1)
+	{
+		g_warning ("Error in executing query");
 		g_signal_emit_by_name (query, "async-result", NULL);
+	}
 	else
 	{
 		if (symbol_db_query_result_is_empty (result))
@@ -626,8 +633,7 @@ on_sdb_query_dbe_scan_end (SymbolDBEngine *dbe, gint something,
 	
 	if (query->priv->mode == IANJUTA_SYMBOL_QUERY_MODE_QUEUED &&
 	    query->priv->query_queued &&
-	    !symbol_db_engine_is_scanning (query->priv->dbe_system) &&
-	    !symbol_db_engine_is_scanning (query->priv->dbe_project))
+	    !symbol_db_engine_is_scanning (query->priv->dbe_selected))
 	{
 		sdb_query_handle_result (query, sdb_query_execute_real (query));
 		query->priv->query_queued = FALSE;



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