diff options
author | Pavel Šimerda <psimerda@redhat.com> | 2015-01-15 13:40:11 +0100 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2015-02-16 13:21:55 -0600 |
commit | 41cb54e9ee5491ff74b574c48cf0b603c226586d (patch) | |
tree | 9b884ace5344c4db2ff742d2ea62ef9bd37da2ac | |
parent | 4d88c806cac989ee02e035689be73130fdd558cb (diff) | |
download | network-manager-applet-41cb54e9ee5491ff74b574c48cf0b603c226586d.tar.gz |
applet: simplify initialization and finalization
Finalization is reordered in a way that allows seamless implementation
of appindicator mode. Initialization now only includes objects that
actually need some.
https://bugzilla.gnome.org/show_bug.cgi?id=740574
-rw-r--r-- | src/applet.c | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/src/applet.c b/src/applet.c index c2fac9b4..2ecf591e 100644 --- a/src/applet.c +++ b/src/applet.c @@ -3687,9 +3687,10 @@ static void finalize (GObject *object) if (applet->update_icon_id) g_source_remove (applet->update_icon_id); - if (applet->menu) - g_object_unref (applet->menu); + g_clear_object (&applet->status_icon); + g_clear_object (&applet->menu); g_clear_pointer (&applet->icon_cache, g_hash_table_destroy); + g_clear_object (&applet->fallback_icon); nma_icons_free (applet); g_free (applet->tip); @@ -3702,44 +3703,23 @@ static void finalize (GObject *object) g_object_unref (applet->notification); } - if (applet->info_dialog_ui) - g_object_unref (applet->info_dialog_ui); - - if (applet->gsettings) - g_object_unref (applet->gsettings); - - if (applet->status_icon) - g_object_unref (applet->status_icon); - - if (applet->nm_client) - g_object_unref (applet->nm_client); + g_clear_object (&applet->info_dialog_ui); + g_clear_object (&applet->gsettings); + g_clear_object (&applet->nm_client); #if WITH_MODEM_MANAGER_1 - if (applet->mm1) - g_object_unref (applet->mm1); + g_clear_object (&applet->mm1); #endif - if (applet->fallback_icon) - g_object_unref (applet->fallback_icon); - - if (applet->agent) - g_object_unref (applet->agent); - - if (applet->settings) - g_object_unref (applet->settings); - - if (applet->session_bus) - dbus_g_connection_unref (applet->session_bus); + g_clear_object (&applet->agent); + g_clear_object (&applet->settings); + g_clear_pointer (&applet->session_bus, dbus_g_connection_unref); G_OBJECT_CLASS (nma_parent_class)->finalize (object); } static void nma_init (NMApplet *applet) { - applet->animation_id = 0; - applet->animation_step = 0; - applet->icon_theme = NULL; - applet->notification = NULL; applet->icon_size = 16; } |