diff options
author | rbuj <[email protected]> | 2021-11-28 13:19:58 +0100 |
---|---|---|
committer | Luke from DC <[email protected]> | 2021-12-16 06:52:11 +0000 |
commit | 6fbabd51619c92bcd8584e1bb2f12f2b52904ea6 (patch) | |
tree | 540229310cf7f6d6b60e82fcd2952a6caec31a4a /applets | |
parent | 94f3ec8c654363cd6a245eb9dca7c54f1b8f5649 (diff) | |
download | mate-panel-6fbabd51619c92bcd8584e1bb2f12f2b52904ea6.tar.bz2 mate-panel-6fbabd51619c92bcd8584e1bb2f12f2b52904ea6.tar.xz |
Use g_clear_pointer() and g_clear_object()
Diffstat (limited to 'applets')
-rw-r--r-- | applets/clock/calendar-window.c | 8 | ||||
-rw-r--r-- | applets/clock/clock-face.c | 17 | ||||
-rw-r--r-- | applets/clock/clock-location-tile.c | 14 | ||||
-rw-r--r-- | applets/clock/clock-location.c | 15 | ||||
-rw-r--r-- | applets/clock/clock-map.c | 27 | ||||
-rw-r--r-- | applets/clock/system-timezone.c | 8 | ||||
-rw-r--r-- | applets/fish/fish.c | 28 | ||||
-rw-r--r-- | applets/notification_area/status-notifier/sn-dbus-menu.c | 4 | ||||
-rw-r--r-- | applets/notification_area/status-notifier/sn-item-v0.c | 12 | ||||
-rw-r--r-- | applets/notification_area/system-tray/na-tray.c | 6 |
10 files changed, 38 insertions, 101 deletions
diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c index 8fe2c77c..11003d28 100644 --- a/applets/clock/calendar-window.c +++ b/applets/clock/calendar-window.c @@ -617,17 +617,15 @@ calendar_window_set_prefs_path (CalendarWindow *calwin, !strcmp (calwin->priv->prefs_path, prefs_path)) return; - if (calwin->priv->prefs_path) - g_free (calwin->priv->prefs_path); - calwin->priv->prefs_path = NULL; - + g_free (calwin->priv->prefs_path); if (prefs_path && prefs_path [0]) calwin->priv->prefs_path = g_strdup (prefs_path); + else + calwin->priv->prefs_path = NULL; g_object_notify (G_OBJECT (calwin), "prefs-path"); if (calwin->priv->settings) g_object_unref (calwin->priv->settings); - calwin->priv->settings = g_settings_new_with_path (CLOCK_SCHEMA, calwin->priv->prefs_path); } diff --git a/applets/clock/clock-face.c b/applets/clock/clock-face.c index a30afd13..7340c8a8 100644 --- a/applets/clock/clock-face.c +++ b/applets/clock/clock-face.c @@ -369,20 +369,9 @@ clock_face_finalize (GObject *obj) { ClockFacePrivate *priv = clock_face_get_instance_private (CLOCK_FACE(obj)); - if (priv->location) { - g_object_unref (priv->location); - priv->location = NULL; - } - - if (priv->face_pixbuf) { - g_object_unref (priv->face_pixbuf); - priv->face_pixbuf = NULL; - } - - if (priv->size_widget) { - g_object_unref (priv->size_widget); - priv->size_widget = NULL; - } + g_clear_object (&priv->location); + g_clear_object (&priv->face_pixbuf); + g_clear_object (&priv->size_widget); G_OBJECT_CLASS (clock_face_parent_class)->finalize (obj); diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c index 55bc749a..b70f467c 100644 --- a/applets/clock/clock-location-tile.c +++ b/applets/clock/clock-location-tile.c @@ -143,19 +143,11 @@ clock_location_tile_finalize (GObject *g_obj) g_signal_handler_disconnect (priv->location, priv->location_weather_updated_id); priv->location_weather_updated_id = 0; - g_object_unref (priv->location); - priv->location = NULL; + g_clear_object (&priv->location); } - if (priv->button_group) { - g_object_unref (priv->button_group); - priv->button_group = NULL; - } - - if (priv->current_group) { - g_object_unref (priv->current_group); - priv->current_group = NULL; - } + g_clear_object (&priv->button_group); + g_clear_object (&priv->current_group); G_OBJECT_CLASS (clock_location_tile_parent_class)->finalize (g_obj); } diff --git a/applets/clock/clock-location.c b/applets/clock/clock-location.c index 67af64b1..637d834d 100644 --- a/applets/clock/clock-location.c +++ b/applets/clock/clock-location.c @@ -210,17 +210,14 @@ clock_location_finalize (GObject *g_obj) G_CALLBACK (network_changed), CLOCK_LOCATION (g_obj)); - g_free (priv->name); - g_free (priv->city); + g_clear_pointer (&priv->name, g_free); + g_clear_pointer (&priv->city, g_free); - if (priv->systz) { - g_object_unref (priv->systz); - priv->systz = NULL; - } + g_clear_object (&priv->systz); - g_free (priv->timezone); - g_free (priv->tzname); - g_free (priv->weather_code); + g_clear_pointer (&priv->timezone, g_free); + g_clear_pointer (&priv->tzname, g_free); + g_clear_pointer (&priv->weather_code, g_free); if (priv->weather_info) { weather_info_free (priv->weather_info); diff --git a/applets/clock/clock-map.c b/applets/clock/clock-map.c index fc096c60..97441c62 100644 --- a/applets/clock/clock-map.c +++ b/applets/clock/clock-map.c @@ -150,32 +150,15 @@ clock_map_finalize (GObject *g_obj) priv->highlight_timeout_id = 0; } - if (priv->stock_map_pixbuf) { - g_object_unref (priv->stock_map_pixbuf); - priv->stock_map_pixbuf = NULL; - } + g_clear_object (&priv->stock_map_pixbuf); for (i = 0; i < MARKER_NB; i++) { - if (priv->location_marker_pixbuf[i]) { - g_object_unref (priv->location_marker_pixbuf[i]); - priv->location_marker_pixbuf[i] = NULL; - } + g_clear_object (&priv->location_marker_pixbuf[i]); } - if (priv->location_map_pixbuf) { - g_object_unref (priv->location_map_pixbuf); - priv->location_map_pixbuf = NULL; - } - - if (priv->shadow_pixbuf) { - g_object_unref (priv->shadow_pixbuf); - priv->shadow_pixbuf = NULL; - } - - if (priv->shadow_map_pixbuf) { - g_object_unref (priv->shadow_map_pixbuf); - priv->shadow_map_pixbuf = NULL; - } + g_clear_object (&priv->location_map_pixbuf); + g_clear_object (&priv->shadow_pixbuf); + g_clear_object (&priv->shadow_map_pixbuf); G_OBJECT_CLASS (clock_map_parent_class)->finalize (g_obj); } diff --git a/applets/clock/system-timezone.c b/applets/clock/system-timezone.c index 801f3386..b7b3d64b 100644 --- a/applets/clock/system-timezone.c +++ b/applets/clock/system-timezone.c @@ -234,13 +234,11 @@ system_timezone_finalize (GObject *obj) systz = SYSTEM_TIMEZONE (obj); priv = system_timezone_get_instance_private (systz); - g_free (priv->tz); - g_free (priv->env_tz); + g_clear_pointer (&priv->tz, g_free); + g_clear_pointer (&priv->env_tz, g_free); for (i = 0; i < CHECK_NB; i++) { - if (priv->monitors[i]) - g_object_unref (priv->monitors[i]); - priv->monitors[i] = NULL; + g_clear_object (&priv->monitors[i]); } G_OBJECT_CLASS (system_timezone_parent_class)->finalize (obj); diff --git a/applets/fish/fish.c b/applets/fish/fish.c index 2cded044..cfbdf3fa 100644 --- a/applets/fish/fish.c +++ b/applets/fish/fish.c @@ -1778,28 +1778,14 @@ static void fish_applet_dispose (GObject *object) fish); if (fish->timeout) - { g_source_remove (fish->timeout); - } - fish->timeout = 0; - if (fish->settings) - g_object_unref (fish->settings); - fish->settings = NULL; - - if (fish->lockdown_settings) - g_object_unref (fish->lockdown_settings); - fish->lockdown_settings = NULL; - - g_free (fish->name); - fish->name = NULL; - - g_free (fish->image); - fish->image = NULL; - - g_free (fish->command); - fish->command = NULL; + g_clear_object (&fish->settings); + g_clear_object (&fish->lockdown_settings); + g_clear_pointer (&fish->name, g_free); + g_clear_pointer (&fish->image, g_free); + g_clear_pointer (&fish->command, g_free); if (fish->surface) cairo_surface_destroy (fish->surface); @@ -1807,9 +1793,7 @@ static void fish_applet_dispose (GObject *object) fish->surface_width = 0; fish->surface_height = 0; - if (fish->pixbuf) - g_object_unref (fish->pixbuf); - fish->pixbuf = NULL; + g_clear_object (&fish->pixbuf); if (fish->preferences_dialog) gtk_widget_destroy (fish->preferences_dialog); diff --git a/applets/notification_area/status-notifier/sn-dbus-menu.c b/applets/notification_area/status-notifier/sn-dbus-menu.c index 03a95a4b..323663a5 100644 --- a/applets/notification_area/status-notifier/sn-dbus-menu.c +++ b/applets/notification_area/status-notifier/sn-dbus-menu.c @@ -419,8 +419,8 @@ sn_dbus_menu_finalize (GObject *object) menu = SN_DBUS_MENU (object); - g_free (menu->bus_name); - g_free (menu->object_path); + g_clear_pointer (&menu->bus_name, g_free); + g_clear_pointer (&menu->object_path, g_free); G_OBJECT_CLASS (sn_dbus_menu_parent_class)->finalize (object); } diff --git a/applets/notification_area/status-notifier/sn-item-v0.c b/applets/notification_area/status-notifier/sn-item-v0.c index 3ec4d037..d302cbf9 100644 --- a/applets/notification_area/status-notifier/sn-item-v0.c +++ b/applets/notification_area/status-notifier/sn-item-v0.c @@ -640,7 +640,7 @@ update_title (GObject *source_object, v0 = SN_ITEM_V0 (user_data); - g_clear_pointer (&v0->title, g_free); + g_free (v0->title); v0->title = g_variant_dup_string (variant, NULL); g_clear_pointer (&variant, g_variant_unref); @@ -668,7 +668,7 @@ update_icon_name (GObject *source_object, v0 = SN_ITEM_V0 (user_data); - g_clear_pointer (&v0->icon_name, g_free); + g_free (v0->icon_name); v0->icon_name = g_variant_dup_string (variant, NULL); g_clear_pointer (&variant, g_variant_unref); @@ -719,7 +719,7 @@ update_overlay_icon_name (GObject *source_object, v0 = SN_ITEM_V0 (user_data); - g_clear_pointer (&v0->overlay_icon_name, g_free); + g_free (v0->overlay_icon_name); v0->overlay_icon_name = g_variant_dup_string (variant, NULL); g_clear_pointer (&variant, g_variant_unref); @@ -770,7 +770,7 @@ update_attention_icon_name (GObject *source_object, v0 = SN_ITEM_V0 (user_data); - g_clear_pointer (&v0->attention_icon_name, g_free); + g_free (v0->attention_icon_name); v0->attention_icon_name = g_variant_dup_string (variant, NULL); g_clear_pointer (&variant, g_variant_unref); @@ -792,7 +792,7 @@ update_attention_icon_pixmap (GObject *source_object, v0 = SN_ITEM_V0 (user_data); - g_clear_pointer (&v0->attention_icon_pixmap, icon_pixmap_free); + icon_pixmap_free (v0->attention_icon_pixmap); v0->attention_icon_pixmap = icon_pixmap_new (variant); g_clear_pointer (&variant, g_variant_unref); @@ -821,7 +821,7 @@ update_tooltip (GObject *source_object, v0 = SN_ITEM_V0 (user_data); - g_clear_pointer (&v0->tooltip, sn_tooltip_free); + sn_tooltip_free (v0->tooltip); v0->tooltip = sn_tooltip_new (variant); g_clear_pointer (&variant, g_variant_unref); diff --git a/applets/notification_area/system-tray/na-tray.c b/applets/notification_area/system-tray/na-tray.c index fee75dc8..df5c6791 100644 --- a/applets/notification_area/system-tray/na-tray.c +++ b/applets/notification_area/system-tray/na-tray.c @@ -161,13 +161,9 @@ static void icon_tip_buffer_free (gpointer data, gpointer userdata) { - IconTipBuffer *buffer; - - buffer = data; + IconTipBuffer *buffer = data; g_free (buffer->text); - buffer->text = NULL; - g_free (buffer); } |