From 7d8f97e3e07f65b90fed9a10de78cdb285acc455 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Sun, 3 Jan 2010 22:24:20 -0200 Subject: Fixed a bug that would crash the shell if there were ShellFieldUpdates timers pending after modules were unloaded. --- hardinfo2/shell.c | 36 ++++++++++++++++++++---------------- hardinfo2/shell.h | 1 + hardinfo2/util.c | 1 + 3 files changed, 22 insertions(+), 16 deletions(-) (limited to 'hardinfo2') diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 104c99a6..00c5d63c 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -1310,6 +1310,25 @@ void shell_set_note_from_entry(ShellModuleEntry * entry) } } +void shell_clear_field_updates(void) +{ + if (update_sfusrc) { + GSList *sfusrc; + + for (sfusrc = update_sfusrc; sfusrc; sfusrc = sfusrc->next) { + ShellFieldUpdateSource *src = + (ShellFieldUpdateSource *) sfusrc->data; + g_source_remove(src->source_id); + g_free(src->sfu->field_name); + g_free(src->sfu); + g_free(src); + } + + g_slist_free(update_sfusrc); + update_sfusrc = NULL; + } +} + static void module_selected_show_info(ShellModuleEntry * entry, gboolean reload) { @@ -1337,22 +1356,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) h_hash_table_remove_all(update_tbl); } - if (update_sfusrc) { - GSList *sfusrc; - - for (sfusrc = update_sfusrc; sfusrc; sfusrc = sfusrc->next) { - ShellFieldUpdateSource *src = - (ShellFieldUpdateSource *) sfusrc->data; - - g_source_remove(src->source_id); - g_free(src->sfu->field_name); - g_free(src->sfu); - g_free(src); - } - - g_slist_free(update_sfusrc); - update_sfusrc = NULL; - } + shell_clear_field_updates(); store = GTK_TREE_STORE(shell->info->model); diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h index 90e7bdc1..7f31c14c 100644 --- a/hardinfo2/shell.h +++ b/hardinfo2/shell.h @@ -197,6 +197,7 @@ void shell_view_set_enabled(gboolean setting); void shell_clear_timeouts(Shell *shell); void shell_clear_tree_models(Shell *shell); +void shell_clear_field_updates(void); void shell_set_title(Shell *shell, char *subtitle); void shell_add_modules_to_gui(gpointer _shell_module, gpointer _shell_tree); diff --git a/hardinfo2/util.c b/hardinfo2/util.c index 67277b53..131f667e 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -640,6 +640,7 @@ void module_unload_all(void) sync_manager_clear_entries(); shell_clear_timeouts(shell); shell_clear_tree_models(shell); + shell_clear_field_updates(); shell_set_title(shell, NULL); g_slist_free(shell->tree->modules); -- cgit v1.2.3