summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-11-11 17:01:57 +0100
committerThomas Haller <thaller@redhat.com>2016-11-22 11:47:29 +0100
commita300093f8f219311ebae3241b491d333d3ca3816 (patch)
tree5aa32f10b751d82ce904df7b20f9318dbff7ad3b
parent0cc660978f9aeaff718a5c79e3fa51fcce3116b7 (diff)
downloadnetwork-manager-applet-a300093f8f219311ebae3241b491d333d3ca3816.tar.gz
c-e: cleanup NMConnectionEditor dispose()
-rw-r--r--src/connection-editor/nm-connection-editor.c55
-rw-r--r--src/connection-editor/nm-connection-editor.h2
2 files changed, 19 insertions, 38 deletions
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 45a95b09..85fc8ff5 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -308,68 +308,49 @@ static void
dispose (GObject *object)
{
NMConnectionEditor *editor = NM_CONNECTION_EDITOR (object);
- GSList *iter;
- if (editor->disposed)
- goto out;
editor->disposed = TRUE;
- if (active_editors)
+ if (active_editors && editor->orig_connection)
g_hash_table_remove (active_editors, editor->orig_connection);
- g_slist_foreach (editor->initializing_pages, (GFunc) g_object_unref, NULL);
- g_slist_free (editor->initializing_pages);
+ g_slist_free_full (editor->initializing_pages, g_object_unref);
editor->initializing_pages = NULL;
- g_slist_foreach (editor->pages, (GFunc) g_object_unref, NULL);
- g_slist_free (editor->pages);
+ g_slist_free_full (editor->pages, g_object_unref);
editor->pages = NULL;
/* Mark any in-progress secrets call as canceled; it will clean up after itself. */
if (editor->secrets_call)
editor->secrets_call->canceled = TRUE;
- /* Kill any pending secrets calls */
- for (iter = editor->pending_secrets_calls; iter; iter = g_slist_next (iter)) {
- get_secrets_info_free ((GetSecretsInfo *) iter->data);
+ while (editor->pending_secrets_calls) {
+ get_secrets_info_free ((GetSecretsInfo *) editor->pending_secrets_calls->data);
+ editor->pending_secrets_calls = g_slist_delete_link (editor->pending_secrets_calls, editor->pending_secrets_calls);
}
- g_slist_free (editor->pending_secrets_calls);
- editor->pending_secrets_calls = NULL;
- if (editor->validate_id) {
- g_source_remove (editor->validate_id);
- editor->validate_id = 0;
- }
+ nm_clear_g_source (&editor->validate_id);
+
+ g_clear_object (&editor->connection);
+ g_clear_object (&editor->orig_connection);
- if (editor->connection) {
- g_object_unref (editor->connection);
- editor->connection = NULL;
- }
- if (editor->orig_connection) {
- g_object_unref (editor->orig_connection);
- editor->orig_connection = NULL;
- }
if (editor->window) {
gtk_widget_destroy (editor->window);
editor->window = NULL;
}
- if (editor->parent_window) {
- g_object_unref (editor->parent_window);
- editor->parent_window = NULL;
- }
- if (editor->builder) {
- g_object_unref (editor->builder);
- editor->builder = NULL;
- }
+ g_clear_object (&editor->parent_window);
+ g_clear_object (&editor->builder);
- g_signal_handler_disconnect (editor->client, editor->permission_id);
- g_object_unref (editor->client);
+ nm_clear_g_signal_handler (editor->client, &editor->permission_id);
+ g_clear_object (&editor->client);
g_clear_pointer (&editor->last_validation_error, g_free);
- g_hash_table_destroy (editor->inter_page_hash);
+ if (editor->inter_page_hash) {
+ g_hash_table_destroy (editor->inter_page_hash);
+ editor->inter_page_hash = NULL;
+ }
-out:
G_OBJECT_CLASS (nm_connection_editor_parent_class)->dispose (object);
}
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h
index 76255ab2..ff762df4 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -40,7 +40,7 @@ typedef struct {
GtkWindow *parent_window;
NMClient *client;
- guint permission_id;
+ gulong permission_id;
/* private data */
NMConnection *connection;