[gnome-settings-daemon/benzea/no-tz-cache: 5/5] datetime: Load Olson DB on the fly instead of caching it
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/no-tz-cache: 5/5] datetime: Load Olson DB on the fly instead of caching it
- Date: Mon, 11 Jan 2021 12:28:50 +0000 (UTC)
commit 70cadb750353c398198a6c84e5d78551ebe48851
Author: Benjamin Berg <bberg redhat com>
Date: Sat Apr 25 23:20:30 2020 +0200
datetime: Load Olson DB on the fly instead of caching it
We need the database only quite irregularly (i.e. when the location
change). Just load the database on the fly when we need it, and discard
it afterwards to free up the memory again.
See also: !168
plugins/datetime/gsd-timezone-monitor.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/plugins/datetime/gsd-timezone-monitor.c b/plugins/datetime/gsd-timezone-monitor.c
index b8ed108c..a6e8a48d 100644
--- a/plugins/datetime/gsd-timezone-monitor.c
+++ b/plugins/datetime/gsd-timezone-monitor.c
@@ -49,7 +49,6 @@ typedef struct
GClueSimple *geoclue_simple;
GCancellable *geoclue_cancellable;
- TzDB *tzdb;
gchar *current_timezone;
GSettings *location_settings;
@@ -175,15 +174,17 @@ find_timezone (GsdTimezoneMonitor *self,
GeocodeLocation *location,
const gchar *country_code)
{
+ TzDB *tzdb;
gchar *res;
GList *filtered;
GList *weather_locations;
GList *locations;
- GsdTimezoneMonitorPrivate *priv = gsd_timezone_monitor_get_instance_private (self);
TzLocation *closest_tz_location;
+ tzdb = tz_load_db ();
+
/* First load locations from Olson DB */
- locations = ptr_array_to_list (tz_get_locations (priv->tzdb));
+ locations = ptr_array_to_list (tz_get_locations (tzdb));
g_return_val_if_fail (locations != NULL, NULL);
/* ... and then add libgweather's locations as well */
@@ -208,6 +209,7 @@ find_timezone (GsdTimezoneMonitor *self,
g_list_free (locations);
g_list_free_full (weather_locations, (GDestroyNotify) tz_location_free);
+ tz_db_free (tzdb);
return res;
}
@@ -391,7 +393,6 @@ gsd_timezone_monitor_finalize (GObject *obj)
g_clear_object (&priv->dtm);
g_clear_object (&priv->permission);
g_clear_pointer (&priv->current_timezone, g_free);
- g_clear_pointer (&priv->tzdb, tz_db_free);
g_clear_object (&priv->location_settings);
@@ -463,7 +464,6 @@ gsd_timezone_monitor_init (GsdTimezoneMonitor *self)
}
priv->current_timezone = timedate1_dup_timezone (priv->dtm);
- priv->tzdb = tz_load_db ();
priv->location_settings = g_settings_new ("org.gnome.system.location");
g_signal_connect_swapped (priv->location_settings, "changed::enabled",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]