devhelp r1222 - in trunk: . src
- From: rhult svn gnome org
- To: svn-commits-list gnome org
- Subject: devhelp r1222 - in trunk: . src
- Date: Wed, 22 Oct 2008 13:16:35 +0000 (UTC)
Author: rhult
Date: Wed Oct 22 13:16:35 2008
New Revision: 1222
URL: http://svn.gnome.org/viewvc/devhelp?rev=1222&view=rev
Log:
2008-10-22 Richard Hult <richard imendio com>
Bug 557223 â segmentation fault on startup
* src/ige-conf-gconf.c:
* src/ige-conf-private.h:
* src/ige-conf.c: Add back simple fallbacks for people with
mis-configured gconf setups.
Modified:
trunk/ChangeLog
trunk/src/ige-conf-gconf.c
trunk/src/ige-conf-private.h
trunk/src/ige-conf.c
Modified: trunk/src/ige-conf-gconf.c
==============================================================================
--- trunk/src/ige-conf-gconf.c (original)
+++ trunk/src/ige-conf-gconf.c Wed Oct 22 13:16:35 2008
@@ -25,6 +25,7 @@
typedef struct {
GConfClient *gconf_client;
+ GList *defaults;
} IgeConfPriv;
typedef struct {
@@ -55,6 +56,8 @@
g_object_unref (priv->gconf_client);
+ _ige_conf_defaults_free_list (priv->defaults);
+
G_OBJECT_CLASS (ige_conf_parent_class)->finalize (object);
}
@@ -95,11 +98,10 @@
const gchar *path)
{
IgeConfPriv *priv = GET_PRIVATE (conf);
- GList *defaults;
gchar *root;
- defaults = _ige_conf_defaults_read_file (path, NULL);
- root = _ige_conf_defaults_get_root (defaults);
+ priv->defaults = _ige_conf_defaults_read_file (path, NULL);
+ root = _ige_conf_defaults_get_root (priv->defaults);
gconf_client_add_dir (priv->gconf_client,
root,
@@ -107,7 +109,18 @@
NULL);
g_free (root);
- _ige_conf_defaults_free_list (defaults);
+}
+
+static GConfEntry *
+conf_get_entry (IgeConf *conf,
+ const gchar *key)
+{
+ IgeConfPriv *priv;
+
+ priv = GET_PRIVATE (conf);
+
+ return gconf_client_get_entry (priv->gconf_client, key,
+ NULL, TRUE, NULL);
}
gboolean
@@ -133,7 +146,8 @@
gint *value)
{
IgeConfPriv *priv;
- GError *error = NULL;
+ GConfEntry *entry;
+ gboolean got_value = FALSE;
*value = 0;
@@ -142,13 +156,21 @@
priv = GET_PRIVATE (conf);
- *value = gconf_client_get_int (priv->gconf_client,
- key,
- &error);
+ entry = conf_get_entry (conf, key);
+ if (entry) {
+ GConfValue *v;
+
+ v = gconf_entry_get_value (entry);
+ if (v) {
+ *value = gconf_value_get_int (v);
+ got_value = TRUE;
+ }
+ }
- if (error) {
- g_error_free (error);
- return FALSE;
+ gconf_entry_free (entry);
+
+ if (!got_value) {
+ *value = _ige_conf_defaults_get_int (priv->defaults, key);
}
return TRUE;
@@ -177,22 +199,31 @@
gboolean *value)
{
IgeConfPriv *priv;
- GError *error = NULL;
+ GConfEntry *entry;
+ gboolean got_value = FALSE;
- *value = FALSE;
+ *value = 0;
g_return_val_if_fail (IGE_IS_CONF (conf), FALSE);
g_return_val_if_fail (value != NULL, FALSE);
priv = GET_PRIVATE (conf);
- *value = gconf_client_get_bool (priv->gconf_client,
- key,
- &error);
+ entry = conf_get_entry (conf, key);
+ if (entry) {
+ GConfValue *v;
+
+ v = gconf_entry_get_value (entry);
+ if (v) {
+ *value = gconf_value_get_bool (v);
+ got_value = TRUE;
+ }
+ }
- if (error) {
- g_error_free (error);
- return FALSE;
+ gconf_entry_free (entry);
+
+ if (!got_value) {
+ *value = _ige_conf_defaults_get_bool (priv->defaults, key);
}
return TRUE;
@@ -238,6 +269,10 @@
return FALSE;
}
+ if (*value == NULL) {
+ *value = g_strdup (_ige_conf_defaults_get_string (priv->defaults, key));
+ }
+
return TRUE;
}
Modified: trunk/src/ige-conf-private.h
==============================================================================
--- trunk/src/ige-conf-private.h (original)
+++ trunk/src/ige-conf-private.h Wed Oct 22 13:16:35 2008
@@ -38,10 +38,16 @@
gchar *value;
} IgeConfDefaultItem;
-GList *_ige_conf_defaults_read_file (const gchar *path,
- GError **error);
-void _ige_conf_defaults_free_list (GList *defaults);
-gchar *_ige_conf_defaults_get_root (GList *defaults);
+GList * _ige_conf_defaults_read_file (const gchar *path,
+ GError **error);
+void _ige_conf_defaults_free_list (GList *defaults);
+gchar * _ige_conf_defaults_get_root (GList *defaults);
+const gchar *_ige_conf_defaults_get_string (GList *defaults,
+ const gchar *key);
+gint _ige_conf_defaults_get_int (GList *defaults,
+ const gchar *key);
+gboolean _ige_conf_defaults_get_bool (GList *defaults,
+ const gchar *key);
G_END_DECLS
Modified: trunk/src/ige-conf.c
==============================================================================
--- trunk/src/ige-conf.c (original)
+++ trunk/src/ige-conf.c Wed Oct 22 13:16:35 2008
@@ -20,6 +20,7 @@
#include "config.h"
#include <string.h>
+#include <stdlib.h>
#include "ige-conf-private.h"
typedef struct {
@@ -267,3 +268,70 @@
return root;
}
+
+static IgeConfDefaultItem *
+defaults_get_item (GList *defaults,
+ const gchar *key)
+{
+ GList *l;
+
+ for (l = defaults; l; l = l->next) {
+ IgeConfDefaultItem *item = l->data;
+
+ if (strcmp (item->key, key) == 0) {
+ return item;
+ }
+ }
+
+ return NULL;
+}
+
+const gchar *
+_ige_conf_defaults_get_string (GList *defaults,
+ const gchar *key)
+{
+ IgeConfDefaultItem *item;
+
+ item = defaults_get_item (defaults, key);
+
+ if (item) {
+ return item->value;
+ }
+
+ return NULL;
+}
+
+gint
+_ige_conf_defaults_get_int (GList *defaults,
+ const gchar *key)
+{
+ IgeConfDefaultItem *item;
+
+ item = defaults_get_item (defaults, key);
+
+ if (item) {
+ return strtol (item->value, NULL, 10);
+ }
+
+ return 0;
+}
+
+gboolean
+_ige_conf_defaults_get_bool (GList *defaults,
+ const gchar *key)
+{
+ IgeConfDefaultItem *item;
+
+ item = defaults_get_item (defaults, key);
+
+ if (item) {
+ if (strcmp (item->value, "false") == 0) {
+ return FALSE;
+ }
+ else if (strcmp (item->value, "true") == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]