[gnome-control-center/wip/carlosg/ethernet-dialog-crash] network: Keep a ref on NetDeviceEthernet while a edition dialog is open



commit 44ef47fbca07d69ef6d7325db7361cc346a2bd99
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Nov 28 16:38:03 2019 +0100

    network: Keep a ref on NetDeviceEthernet while a edition dialog is open
    
    Otherwise, invoking other panel (eg. through shell search, or CLI) and
    closing the dialog will result in a crash, as the NetDeviceEthernet
    object does no longer exist.

 panels/network/net-device-ethernet.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index 2177657a5..16564e627 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -212,6 +212,7 @@ static void
 editor_done (NetDeviceEthernet *self)
 {
         device_ethernet_refresh_ui (self);
+        g_object_unref (self);
 }
 
 static void
@@ -230,7 +231,7 @@ show_details (NetDeviceEthernet *self, GtkButton *button, const gchar *title)
         editor = net_connection_editor_new (GTK_WINDOW (window), connection, self->device, NULL, 
self->client);
         if (title)
                 net_connection_editor_set_title (editor, title);
-        g_signal_connect_swapped (editor, "done", G_CALLBACK (editor_done), self);
+        g_signal_connect_swapped (editor, "done", G_CALLBACK (editor_done), g_object_ref (self));
         net_connection_editor_run (editor);
 }
 
@@ -383,6 +384,7 @@ static void
 client_connection_added_cb (NetDeviceEthernet  *self)
 {
         device_ethernet_refresh_ui (self);
+        g_object_unref (self);
 }
 
 static void
@@ -417,7 +419,7 @@ add_profile_button_clicked_cb (NetDeviceEthernet *self)
         window = gtk_widget_get_toplevel (GTK_WIDGET (self));
 
         editor = net_connection_editor_new (GTK_WINDOW (window), connection, self->device, NULL, 
self->client);
-        g_signal_connect_swapped (editor, "done", G_CALLBACK (editor_done), self);
+        g_signal_connect_swapped (editor, "done", G_CALLBACK (editor_done), g_object_ref (self));
         net_connection_editor_run (editor);
 }
 


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