[geany/geany-plugins] d1f6bd: gproject: Don't use g_hash_table_iter_replace() and g_hash_table_contains()

Jiří Techet git-noreply at xxxxx
Wed Dec 17 19:48:20 UTC 2014


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Wed, 17 Dec 2014 19:48:20 UTC
Commit:      d1f6bde87b0f9662b63ad20014a720c7460d3def
             https://github.com/geany/geany-plugins/commit/d1f6bde87b0f9662b63ad20014a720c7460d3def

Log Message:
-----------
gproject: Don't use g_hash_table_iter_replace() and g_hash_table_contains()

These functions aren't available on systems with older glib versions.


Modified Paths:
--------------
    gproject/src/gproject-project.c

Modified: gproject/src/gproject-project.c
9 lines changed, 7 insertions(+), 2 deletions(-)
===================================================================
@@ -239,8 +239,10 @@ static void regenerate_tags(GPrjRoot *root, gpointer user_data)
 	GHashTableIter iter;
 	gpointer key, value;
 	GPtrArray *source_files;
+	GHashTable *file_table;
 
 	source_files = g_ptr_array_new();
+	file_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GFreeFunc)tm_source_file_free);
 	g_hash_table_iter_init(&iter, root->file_table);
 	while (g_hash_table_iter_next(&iter, &key, &value))
 	{
@@ -251,8 +253,11 @@ static void regenerate_tags(GPrjRoot *root, gpointer user_data)
 		if (sf && !document_find_by_filename(path))
 			g_ptr_array_add(source_files, sf);
 		
-		g_hash_table_iter_replace(&iter, sf);
+		g_hash_table_insert(file_table, g_strdup(path), sf);
 	}
+	g_hash_table_destroy(root->file_table);
+	root->file_table = file_table;
+
 	tm_workspace_add_source_files(source_files);
 	g_ptr_array_free(source_files, TRUE);
 }
@@ -627,7 +632,7 @@ gboolean gprj_project_is_in_project(const gchar * filename)
 	foreach_slist (elem, g_prj->roots)
 	{
 		GPrjRoot *root = elem->data;
-		if (g_hash_table_contains(root->file_table, filename))
+		if (g_hash_table_lookup_extended (root->file_table, filename, NULL, NULL))
 			return TRUE;
 	}
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list