diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-09-05 21:55:46 -0300 |
---|---|---|
committer | Debarshi Ray <debarshir@gnome.org> | 2013-09-09 16:24:37 +0200 |
commit | 00d8f80586268a14860f2b31be6556f1c1acf2dc (patch) | |
tree | a97a638aad6d9d05af1d6b2a8af1d42e6c62742d | |
parent | 531989217e7c4e3aeed4b8650cfd239acc9dcfb1 (diff) | |
download | gnome-control-center-00d8f80586268a14860f2b31be6556f1c1acf2dc.tar.gz |
background: Use g_clear_* helpers when possible
https://bugzilla.gnome.org/show_bug.cgi?id=707602
-rw-r--r-- | panels/background/bg-flickr-source.c | 13 | ||||
-rw-r--r-- | panels/background/bg-pictures-source.c | 21 | ||||
-rw-r--r-- | panels/background/bg-source.c | 6 | ||||
-rw-r--r-- | panels/background/bg-wallpapers-source.c | 12 | ||||
-rw-r--r-- | panels/background/cc-background-item.c | 6 | ||||
-rw-r--r-- | panels/background/cc-background-panel.c | 15 | ||||
-rw-r--r-- | panels/background/cc-background-xml.c | 10 |
7 files changed, 18 insertions, 65 deletions
diff --git a/panels/background/bg-flickr-source.c b/panels/background/bg-flickr-source.c index 7915b7f00..6c60eef2e 100644 --- a/panels/background/bg-flickr-source.c +++ b/panels/background/bg-flickr-source.c @@ -46,17 +46,8 @@ bg_flickr_source_dispose (GObject *object) { BgFlickrSourcePrivate *priv = BG_FLICKR_SOURCE (object)->priv; - if (priv->client) - { - g_object_unref (priv->client); - priv->client = NULL; - } - - if (priv->service) - { - g_object_unref (priv->service); - priv->service = NULL; - } + g_clear_object (&priv->client); + g_clear_object (&priv->service); G_OBJECT_CLASS (bg_flickr_source_parent_class)->dispose (object); } diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c index b678e61bc..86414f1b2 100644 --- a/panels/background/bg-pictures-source.c +++ b/panels/background/bg-pictures-source.c @@ -94,15 +94,10 @@ bg_pictures_source_dispose (GObject *object) if (priv->cancellable) { g_cancellable_cancel (priv->cancellable); - g_object_unref (priv->cancellable); - priv->cancellable = NULL; + g_clear_object (&priv->cancellable); } - if (priv->thumb_factory) - { - g_object_unref (priv->thumb_factory); - priv->thumb_factory = NULL; - } + g_clear_object (&priv->thumb_factory); G_OBJECT_CLASS (bg_pictures_source_parent_class)->dispose (object); } @@ -112,17 +107,9 @@ bg_pictures_source_finalize (GObject *object) { BgPicturesSource *bg_source = BG_PICTURES_SOURCE (object); - if (bg_source->priv->thumb_factory) - { - g_object_unref (bg_source->priv->thumb_factory); - bg_source->priv->thumb_factory = NULL; - } + g_clear_object (&bg_source->priv->thumb_factory); - if (bg_source->priv->known_items) - { - g_hash_table_destroy (bg_source->priv->known_items); - bg_source->priv->known_items = NULL; - } + g_clear_pointer (&bg_source->priv->known_items, g_hash_table_destroy); g_clear_object (&bg_source->priv->picture_dir_monitor); g_clear_object (&bg_source->priv->cache_dir_monitor); diff --git a/panels/background/bg-source.c b/panels/background/bg-source.c index 50bd3506c..6a230a48b 100644 --- a/panels/background/bg-source.c +++ b/panels/background/bg-source.c @@ -75,11 +75,7 @@ bg_source_dispose (GObject *object) { BgSourcePrivate *priv = BG_SOURCE (object)->priv; - if (priv->store) - { - g_object_unref (priv->store); - priv->store = NULL; - } + g_clear_object (&priv->store); G_OBJECT_CLASS (bg_source_parent_class)->dispose (object); } diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c index 03978f2f4..b2f01396b 100644 --- a/panels/background/bg-wallpapers-source.c +++ b/panels/background/bg-wallpapers-source.c @@ -72,16 +72,8 @@ bg_wallpapers_source_dispose (GObject *object) { BgWallpapersSourcePrivate *priv = BG_WALLPAPERS_SOURCE (object)->priv; - if (priv->thumb_factory) - { - g_object_unref (priv->thumb_factory); - priv->thumb_factory = NULL; - } - if (priv->xml) - { - g_object_unref (priv->xml); - priv->xml = NULL; - } + g_clear_object (&priv->thumb_factory); + g_clear_object (&priv->xml); G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->dispose (object); } diff --git a/panels/background/cc-background-item.c b/panels/background/cc-background-item.c index 8f6e1d233..6e220a9e3 100644 --- a/panels/background/cc-background-item.c +++ b/panels/background/cc-background-item.c @@ -140,8 +140,7 @@ cc_background_item_changes_with_time (CcBackgroundItem *item) static void update_size (CcBackgroundItem *item) { - g_free (item->priv->size); - item->priv->size = NULL; + g_clear_pointer (&item->priv->size, g_free); if (item->priv->uri == NULL) { item->priv->size = g_strdup (""); @@ -272,8 +271,7 @@ update_info (CcBackgroundItem *item, info = g_object_ref (_info); } - g_free (item->priv->mime_type); - item->priv->mime_type = NULL; + g_clear_pointer (&item->priv->mime_type, g_free); if (info == NULL || g_file_info_get_content_type (info) == NULL) { diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c index 9a34f500e..752a8279f 100644 --- a/panels/background/cc-background-panel.c +++ b/panels/background/cc-background-panel.c @@ -101,8 +101,7 @@ cc_background_panel_dispose (GObject *object) /* cancel any copy operation */ g_cancellable_cancel (priv->copy_cancellable); - g_object_unref (priv->copy_cancellable); - priv->copy_cancellable = NULL; + g_clear_object (&priv->copy_cancellable); } if (priv->capture_cancellable) @@ -110,8 +109,7 @@ cc_background_panel_dispose (GObject *object) /* cancel screenshot operations */ g_cancellable_cancel (priv->capture_cancellable); - g_object_unref (priv->capture_cancellable); - priv->capture_cancellable = NULL; + g_clear_object (&priv->capture_cancellable); } if (priv->chooser) @@ -123,8 +121,7 @@ cc_background_panel_dispose (GObject *object) g_clear_object (&priv->thumb_factory); g_clear_object (&priv->display_screenshot); - g_free (priv->screenshot_path); - priv->screenshot_path = NULL; + g_clear_pointer (&priv->screenshot_path, g_free); g_clear_object (&priv->connection); @@ -344,8 +341,7 @@ on_screenshot_finished (GObject *source, /* remove the temporary file created by the shell */ g_unlink (panel->priv->screenshot_path); - g_free (priv->screenshot_path); - priv->screenshot_path = NULL; + g_clear_pointer (&priv->screenshot_path, g_free); cairo_destroy (cr); cairo_surface_destroy (surface); @@ -478,8 +474,7 @@ reload_current_bg (CcBackgroundPanel *self, uri = g_settings_get_string (settings, WP_URI_KEY); if (uri && *uri == '\0') { - g_free (uri); - uri = NULL; + g_clear_pointer (&uri, g_free); } else { diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c index d31c91f07..d23afbccb 100644 --- a/panels/background/cc-background-xml.c +++ b/panels/background/cc-background-xml.c @@ -623,18 +623,12 @@ cc_background_xml_finalize (GObject *object) g_return_if_fail (xml->priv != NULL); - if (xml->priv->wp_hash) { - g_hash_table_destroy (xml->priv->wp_hash); - xml->priv->wp_hash = NULL; - } + g_clear_pointer (&xml->priv->wp_hash, g_hash_table_destroy); if (xml->priv->item_added_id != 0) { g_source_remove (xml->priv->item_added_id); xml->priv->item_added_id = 0; } - if (xml->priv->item_added_queue) { - g_async_queue_unref (xml->priv->item_added_queue); - xml->priv->item_added_queue = NULL; - } + g_clear_pointer (&xml->priv->item_added_queue, g_async_queue_unref); } static void |