[libchamplain] Fix cache initialization
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Fix cache initialization
- Date: Tue, 16 Feb 2010 21:29:08 +0000 (UTC)
commit d0de19fae484bc4eb7cf7a2d567345b5f86325e8
Author: JiÅ?Ã Techet <techet gmail com>
Date: Mon Feb 15 00:59:57 2010 +0100
Fix cache initialization
init_cache() should be called only when all properties are set (that is
inside the _constructed() method)
Signed-off-by: JiÅ?Ã Techet <techet gmail com>
champlain/champlain-file-cache.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/champlain/champlain-file-cache.c b/champlain/champlain-file-cache.c
index 0c8b915..46ef0fe 100644
--- a/champlain/champlain-file-cache.c
+++ b/champlain/champlain-file-cache.c
@@ -119,6 +119,8 @@ champlain_file_cache_set_property (GObject *object,
champlain_file_cache_set_size_limit (file_cache, g_value_get_uint (value));
break;
case PROP_CACHE_DIR:
+ if (priv->cache_dir)
+ g_free (priv->cache_dir);
priv->cache_dir = g_strdup (g_value_get_string (value));
break;
default:
@@ -324,12 +326,23 @@ init_cache (ChamplainFileCache *file_cache)
}
static void
+champlain_file_cache_constructed (GObject *object)
+{
+ ChamplainFileCache *file_cache = CHAMPLAIN_FILE_CACHE(object);
+
+ init_cache (file_cache);
+
+ G_OBJECT_CLASS (champlain_file_cache_parent_class)->constructed (object);
+}
+
+static void
champlain_file_cache_class_init (ChamplainFileCacheClass *klass)
{
ChamplainMapSourceClass *map_source_class = CHAMPLAIN_MAP_SOURCE_CLASS (klass);
ChamplainTileCacheClass *tile_cache_class = CHAMPLAIN_TILE_CACHE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
+ gchar *cache_dir;
g_type_class_add_private (klass, sizeof (ChamplainFileCachePrivate));
@@ -337,6 +350,7 @@ champlain_file_cache_class_init (ChamplainFileCacheClass *klass)
object_class->dispose = champlain_file_cache_dispose;
object_class->get_property = champlain_file_cache_get_property;
object_class->set_property = champlain_file_cache_set_property;
+ object_class->constructed = champlain_file_cache_constructed;
/**
* ChamplainFileCache:size-limit:
@@ -356,6 +370,12 @@ champlain_file_cache_class_init (ChamplainFileCacheClass *klass)
G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_SIZE_LIMIT, pspec);
+#ifdef USE_MAEMO
+ cache_dir = g_strdup ("/home/user/MyDocs/.Maps/");
+#else
+ cache_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (), "champlain", NULL);
+#endif
+
/**
* ChamplainFileCache:cache-dir:
*
@@ -366,7 +386,7 @@ champlain_file_cache_class_init (ChamplainFileCacheClass *klass)
pspec = g_param_spec_string ("cache-dir",
"Cache Directory",
"The directory of the cache",
- "",
+ cache_dir,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CACHE_DIR, pspec);
@@ -383,19 +403,15 @@ champlain_file_cache_init (ChamplainFileCache *file_cache)
{
ChamplainFileCachePrivate *priv = GET_PRIVATE (file_cache);
+ /*
+ priv->cache_dir initialized by the default value of the
+ G_PARAM_CONSTRUCT_ONLY property
+ */
priv->size_limit = 100000000;
-#ifdef USE_MAEMO
- priv->cache_dir = g_strdup ("/home/user/MyDocs/.Maps/");
-#else
- priv->cache_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (), "champlain", NULL);
-#endif
-
priv->real_cache_dir = NULL;
priv->db = NULL;
priv->stmt_select = NULL;
priv->stmt_update = NULL;
-
- init_cache (file_cache);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]