[network-manager-applet/th/c-e-import-fixes-bgo774290: 6/10] c-e: cleanup NMConnectionEditor dispose()



commit a300093f8f219311ebae3241b491d333d3ca3816
Author: Thomas Haller <thaller redhat com>
Date:   Fri Nov 11 17:01:57 2016 +0100

    c-e: cleanup NMConnectionEditor dispose()

 src/connection-editor/nm-connection-editor.c |   55 ++++++++-----------------
 src/connection-editor/nm-connection-editor.h |    2 +-
 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 45a95b0..85fc8ff 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 76255ab..ff762df 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;


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