[network-manager-applet/polkit1] editor: fix editor/connection lifetimes
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-applet/polkit1] editor: fix editor/connection lifetimes
- Date: Tue, 25 Aug 2009 20:03:07 +0000 (UTC)
commit 968616ca0697737e03c859dca20c5092457446a3
Author: Dan Williams <dcbw redhat com>
Date: Tue Aug 25 15:02:10 2009 -0500
editor: fix editor/connection lifetimes
The NMConnectionEditor instance refs the NMConnection so we don't
need to unref when removing the connection (which is also the key to
the hash) from list->editors. Make sure the editor gets properly
cleaned up everwhere too.
src/connection-editor/nm-connection-list.c | 44 ++++++++++++++++------------
1 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 6aef00b..62d6bdf 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -591,7 +591,6 @@ static void
add_response_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
- NMConnection *connection;
const char *message = _("An unknown error ocurred.");
if (response == GTK_RESPONSE_OK) {
@@ -605,8 +604,7 @@ add_response_cb (NMConnectionEditor *editor, gint response, GError *error, gpoin
"%s", message);
}
- connection = nm_connection_editor_get_connection (editor);
- g_hash_table_remove (info->list->editors, connection);
+ g_hash_table_remove (info->list->editors, nm_connection_editor_get_connection (editor));
}
static void
@@ -645,7 +643,7 @@ really_add_connection (NMConnection *connection,
return;
}
- g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (add_response_cb), info);
+ g_signal_connect (editor, "done", G_CALLBACK (add_response_cb), info);
g_hash_table_insert (info->list->editors, connection, editor);
nm_connection_editor_run (editor);
@@ -703,6 +701,8 @@ connection_updated_cb (NMConnectionList *list,
if (get_iter_for_connection (GTK_TREE_MODEL (store), connection, &iter))
update_connection_row (store, &iter, connection);
}
+
+ g_hash_table_remove (list->editors, connection);
g_free (info);
}
@@ -712,28 +712,21 @@ edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer
EditInfo *info = user_data;
const char *message = _("An unknown error ocurred.");
NMConnection *connection;
+ GError *edit_error = NULL;
+ gboolean success;
connection = nm_connection_editor_get_connection (editor);
g_assert (connection);
- g_hash_table_remove (info->list->editors, connection);
-
- if (response == GTK_RESPONSE_NONE) {
- if (error && error->message)
- message = error->message;
- error_dialog (GTK_WINDOW (editor->window), _("Error initializing editor"), "%s", message);
- g_free (info);
- return;
- }
-
- if (response == GTK_RESPONSE_OK) {
- GError *edit_error = NULL;
- gboolean success;
+ switch (response) {
+ case GTK_RESPONSE_OK:
+ /* Make sure the connection is valid */
utils_fill_connection_certs (connection);
success = nm_connection_verify (connection, &edit_error);
utils_clear_filled_connection_certs (connection);
if (success) {
+ /* Save the connection to backing storage */
update_connection (info->list,
editor,
NM_SETTINGS_CONNECTION_INTERFACE (connection),
@@ -752,6 +745,19 @@ edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer
info);
g_error_free (edit_error);
}
+ break;
+ case GTK_RESPONSE_NONE:
+ case GTK_RESPONSE_CANCEL:
+ default:
+ if (response == GTK_RESPONSE_NONE) {
+ /* Show an error dialog if the editor initialization failed */
+ if (error && error->message)
+ message = error->message;
+ error_dialog (GTK_WINDOW (editor->window), _("Error initializing editor"), "%s", message);
+ }
+ g_hash_table_remove (info->list->editors, connection);
+ g_free (info);
+ break;
}
}
@@ -990,7 +996,7 @@ import_success_cb (NMConnection *connection, gpointer user_data)
return;
}
- g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (add_response_cb), info);
+ g_signal_connect (editor, "done", G_CALLBACK (add_response_cb), info);
g_hash_table_insert (info->list->editors, connection, editor);
nm_connection_editor_run (editor);
@@ -1481,7 +1487,7 @@ nm_connection_list_new (GType def_type)
add_connection_tabs (list, def_type);
- list->editors = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, g_object_unref);
+ list->editors = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
list->dialog = glade_xml_get_widget (list->gui, "NMConnectionList");
if (!list->dialog)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]