anjuta r4581 - in trunk: . plugins/symbol-db



Author: mcora
Date: Mon Jan 12 18:01:58 2009
New Revision: 4581
URL: http://svn.gnome.org/viewvc/anjuta?rev=4581&view=rev

Log:
	* plugins/symbol-db/plugin.c (do_update_project_symbols),
	(do_check_offline_files_changed), (on_project_root_added):
	* plugins/symbol-db/symbol-db-engine-queries.c
	(symbol_db_engine_is_language_used):
	fixed #567505 â Anjuta hangs while generating inheritances. Was introduced by
	me with last patch.


Modified:
   trunk/ChangeLog
   trunk/plugins/symbol-db/plugin.c
   trunk/plugins/symbol-db/symbol-db-engine-queries.c

Modified: trunk/plugins/symbol-db/plugin.c
==============================================================================
--- trunk/plugins/symbol-db/plugin.c	(original)
+++ trunk/plugins/symbol-db/plugin.c	Mon Jan 12 18:01:58 2009
@@ -1473,7 +1473,10 @@
 	}	
 }
 
-static void
+/**
+ * @return TRUE if a scan is in progress, FALSE elsewhere.
+ */
+static gboolean
 do_update_project_symbols (SymbolDBPlugin *sdb_plugin, const gchar *root_dir)
 {
 	gint proc_id;
@@ -1487,7 +1490,10 @@
 		/* insert the proc id associated within the task */
 		g_tree_insert (sdb_plugin->proc_id_tree, GINT_TO_POINTER (proc_id),
 					   GINT_TO_POINTER (TASK_PROJECT_UPDATE));
+		return TRUE;
 	}
+	
+	return FALSE;
 }
 
 /**
@@ -1526,7 +1532,10 @@
 	}
 }
 
-static void
+/**
+ * @return TRUE is a scan process is started, FALSE elsewhere.
+ */
+static gboolean
 do_check_offline_files_changed (SymbolDBPlugin *sdb_plugin)
 {
 	GList * prj_elements_list;
@@ -1534,6 +1543,7 @@
 	GHashTable *prj_elements_hash;
 	GPtrArray *to_add_files = NULL;
 	gint i;
+	gint real_added ;
 	
 	pm = anjuta_shell_get_interface (ANJUTA_PLUGIN (sdb_plugin)->shell,
 									 IAnjutaProjectManager, NULL);	
@@ -1648,7 +1658,7 @@
 								 sdb_plugin->sdbe_project, FALSE);
 		sdb_plugin->is_offline_scanning = TRUE;		
 		
-		gint real_added = do_add_new_files (sdb_plugin, to_add_files, 
+		real_added = do_add_new_files (sdb_plugin, to_add_files, 
 										   TASK_OFFLINE_CHANGES);
 		
 		DEBUG_PRINT ("going to do add %d files with TASK_OFFLINE_CHANGES",
@@ -1666,6 +1676,8 @@
 	g_object_unref (it);
 	g_ptr_array_free (to_add_files, TRUE);
 	g_hash_table_destroy (prj_elements_hash);
+	
+	return real_added > 0 ? TRUE : FALSE;	
 }
 
 /* add a new project */
@@ -1806,7 +1818,10 @@
 			 * a previous session..
 			 */				
 			GPtrArray *sources_array = NULL;				
-				
+			gboolean flag_offline;
+			gboolean flag_update;
+			
+			
 			sources_array = 
 				symbol_db_engine_get_files_with_zero_symbols (sdb_plugin->sdbe_project);
 
@@ -1819,10 +1834,20 @@
 			}
 				
 			/* check for offline changes */				
-			do_check_offline_files_changed (sdb_plugin);								
+			flag_offline = do_check_offline_files_changed (sdb_plugin);
 				
 			/* update any files of the project which isn't up-to-date */
-			do_update_project_symbols (sdb_plugin, root_dir);
+			flag_update = do_update_project_symbols (sdb_plugin, root_dir);
+			
+			/* if they're both false then there won't be a place where
+			 * the do_check_languages_count () is called. Check the returns
+			 * and to it here
+			 */
+			if (flag_offline == FALSE && flag_update == FALSE)
+			{
+				/* check for the number of languages used in the opened project. */
+				do_check_languages_count (sdb_plugin);				
+			}				
 		}
 		gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sdb_plugin->progress_bar_project),
 								   _("Populating symbols' db..."));
@@ -1848,9 +1873,6 @@
 					  G_CALLBACK (on_project_element_added), sdb_plugin);
 	g_signal_connect (G_OBJECT (pm), "element_removed",
 					  G_CALLBACK (on_project_element_removed), sdb_plugin);
-
-	/* check for the number of languages used in the opened project. */
-	do_check_languages_count (sdb_plugin);
 }
 
 static void

Modified: trunk/plugins/symbol-db/symbol-db-engine-queries.c
==============================================================================
--- trunk/plugins/symbol-db/symbol-db-engine-queries.c	(original)
+++ trunk/plugins/symbol-db/symbol-db-engine-queries.c	Mon Jan 12 18:01:58 2009
@@ -2701,6 +2701,8 @@
 	g_return_val_if_fail (language != NULL, FALSE);
 	
 	priv = dbe->priv;
+	if (priv->mutex)
+		g_mutex_lock (priv->mutex);
 
 	MP_LEND_OBJ_STR(priv, value);
 	g_value_set_static_string (value, language);
@@ -2711,9 +2713,15 @@
 						"langname",
 						value)) < 0)
 	{
+		if (priv->mutex)
+			g_mutex_unlock (priv->mutex);
+	
 		return FALSE;
 	}
-	
+
+	if (priv->mutex)
+		g_mutex_unlock (priv->mutex);
+
 	return TRUE;
 }
 



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