diff options
Diffstat (limited to 'applets/clock/clock-location.c')
-rw-r--r-- | applets/clock/clock-location.c | 69 |
1 files changed, 15 insertions, 54 deletions
diff --git a/applets/clock/clock-location.c b/applets/clock/clock-location.c index 9dc25e4b..637d834d 100644 --- a/applets/clock/clock-location.c +++ b/applets/clock/clock-location.c @@ -92,7 +92,7 @@ clock_location_find_and_ref (GSList *locations, } if (l != NULL) - return g_object_ref (CLOCK_LOCATION (l->data)); + return CLOCK_LOCATION (l->data); else return NULL; } @@ -210,35 +210,14 @@ clock_location_finalize (GObject *g_obj) G_CALLBACK (network_changed), CLOCK_LOCATION (g_obj)); - if (priv->name) { - g_free (priv->name); - priv->name = NULL; - } - - if (priv->city) { - g_free (priv->city); - priv->city = NULL; - } + 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); - if (priv->timezone) { - g_free (priv->timezone); - priv->timezone = NULL; - } - - if (priv->tzname) { - g_free (priv->tzname); - priv->tzname = NULL; - } - - if (priv->weather_code) { - g_free (priv->weather_code); - priv->weather_code = NULL; - } + 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); @@ -277,11 +256,7 @@ clock_location_set_name (ClockLocation *loc, const gchar *name) { ClockLocationPrivate *priv = clock_location_get_instance_private (loc); - if (priv->name) { - g_free (priv->name); - priv->name = NULL; - } - + g_free (priv->name); priv->name = g_strdup (name); } @@ -298,11 +273,7 @@ clock_location_set_city (ClockLocation *loc, const gchar *city) { ClockLocationPrivate *priv = clock_location_get_instance_private (loc); - if (priv->city) { - g_free (priv->city); - priv->city = NULL; - } - + g_free (priv->city); priv->city = g_strdup (city); } @@ -319,11 +290,7 @@ clock_location_set_timezone (ClockLocation *loc, const gchar *timezone) { ClockLocationPrivate *priv = clock_location_get_instance_private (loc); - if (priv->timezone) { - g_free (priv->timezone); - priv->timezone = NULL; - } - + g_free (priv->timezone); priv->timezone = g_strdup (timezone); } @@ -360,16 +327,11 @@ clock_location_set_tzname (ClockLocation *this, const char *tzname) { ClockLocationPrivate *priv = clock_location_get_instance_private (CLOCK_LOCATION(this)); - if (priv->tzname) { - if (strcmp (priv->tzname, tzname) == 0) { - return; - } - - g_free (priv->tzname); - priv->tzname = NULL; - } + if (priv->tzname && strcmp (priv->tzname, tzname) == 0) + return; - if (tzname) { + g_free (priv->tzname); + if (tzname && *tzname != '\0') { priv->tzname = g_strdup (tzname); } else { priv->tzname = NULL; @@ -472,7 +434,6 @@ clock_location_is_current (ClockLocation *loc) return FALSE; } - glong clock_location_get_offset (ClockLocation *loc) { @@ -596,7 +557,7 @@ clock_location_make_current (ClockLocation *loc, static gchar * clock_location_get_valid_weather_code (const gchar *code) { - if (!code || code[0] == '\0') + if (!code || *code == '\0') return g_strdup (WEATHER_EMPTY_CODE); else return g_strdup (code); |