diff options
-rw-r--r-- | hardinfo2/hardinfo.h | 2 | ||||
-rw-r--r-- | hardinfo2/shell.c | 24 | ||||
-rw-r--r-- | hardinfo2/util.c | 13 |
3 files changed, 28 insertions, 11 deletions
diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h index b621cbc9..36dbb6d6 100644 --- a/hardinfo2/hardinfo.h +++ b/hardinfo2/hardinfo.h @@ -98,6 +98,8 @@ gchar *seconds_to_string(unsigned int seconds); gchar *h_strdup_cprintf(const gchar *format, gchar *source, ...); gchar *h_strconcat(gchar *string1, ...); +void h_hash_table_remove_all (GHashTable *hash_table); + void module_entry_scan_all_except(ModuleEntry *entries, gint except_entry); void module_entry_scan_all(ModuleEntry *entries); diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index b4bcc853..c43a2db6 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -544,6 +544,8 @@ void shell_init(GSList * modules) shell->info = info_tree_new(FALSE); shell->moreinfo = info_tree_new(TRUE); shell->loadgraph = load_graph_new(75); + update_tbl = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); gtk_paned_pack1(GTK_PANED(shell->hpaned), shell->tree->scroll, SHELL_PACK_RESIZE, SHELL_PACK_SHRINK); @@ -585,8 +587,14 @@ void shell_init(GSList * modules) static gboolean update_field(gpointer data) { - ShellFieldUpdate *fu = (ShellFieldUpdate *) data; - GtkTreeIter *iter = g_hash_table_lookup(update_tbl, fu->field_name); + ShellFieldUpdate *fu; + GtkTreeIter *iter; + + fu = (ShellFieldUpdate *) data; + g_return_val_if_fail(fu != NULL, FALSE); + + iter = g_hash_table_lookup(update_tbl, fu->field_name); + g_return_val_if_fail(iter != NULL, FALSE); /* if the entry is still selected, update it */ if (iter && fu->entry->selected && fu->entry->fieldfunc) { @@ -1002,9 +1010,8 @@ static void module_selected_show_info(ShellModuleEntry * entry, gboolean reload) { GKeyFile *key_file = g_key_file_new(); - gchar *key_data; - gchar **groups; GtkTreeStore *store; + gchar *key_data, **groups; gint i; gsize ngroups; @@ -1016,14 +1023,9 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) /* recreate the iter hash table */ if (!reload) { - if (update_tbl) { - g_hash_table_destroy(update_tbl); - } - - update_tbl = g_hash_table_new_full(g_str_hash, g_str_equal, - NULL, g_free); + h_hash_table_remove_all(update_tbl); } - + if (update_sfusrc) { GSList *sfusrc; diff --git a/hardinfo2/util.c b/hardinfo2/util.c index bf8c3f57..75cdbfd1 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -1041,3 +1041,16 @@ gchar *h_strconcat(gchar * string1, ...) return concat; } + +static gboolean h_hash_table_remove_all_true(gpointer key, gpointer data, gpointer user_data) +{ + return TRUE; +} + +void +h_hash_table_remove_all(GHashTable *hash_table) +{ + g_hash_table_foreach_remove(hash_table, + h_hash_table_remove_all_true, + NULL); +} |