More careful error handling of values returned by GConf. Fixes #326615.
2006-01-20 Elijah Newren <newren gmail com> More careful error handling of values returned by GConf. Fixes #326615. * src/prefs.c (get_bool): new helper function, (meta_prefs_init): use get_bool to handle the case of a gconf key not existing, (update_cursor_size): sanity check for sane values
This commit is contained in:
parent
af14d9d2a1
commit
a556a7334a
@ -1,3 +1,12 @@
|
|||||||
|
2006-01-20 Elijah Newren <newren gmail com>
|
||||||
|
|
||||||
|
More careful error handling of values returned by GConf. Fixes
|
||||||
|
#326615.
|
||||||
|
|
||||||
|
* src/prefs.c (get_bool): new helper function, (meta_prefs_init):
|
||||||
|
use get_bool to handle the case of a gconf key not existing,
|
||||||
|
(update_cursor_size): sanity check for sane values
|
||||||
|
|
||||||
2006-01-20 Elijah Newren <newren gmail com>
|
2006-01-20 Elijah Newren <newren gmail com>
|
||||||
|
|
||||||
Prevent rapidly repeated visual bells from hanging metacity.
|
Prevent rapidly repeated visual bells from hanging metacity.
|
||||||
|
70
src/prefs.c
70
src/prefs.c
@ -301,6 +301,29 @@ cleanup_error (GError **error)
|
|||||||
*error = NULL;
|
*error = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get_bool returns TRUE if *val is filled in, FALSE otherwise */
|
||||||
|
static gboolean
|
||||||
|
get_bool (const char *key, gboolean *val)
|
||||||
|
{
|
||||||
|
GError *err = NULL;
|
||||||
|
GConfValue *value;
|
||||||
|
gboolean filled_in = FALSE;
|
||||||
|
|
||||||
|
value = gconf_client_get (default_client, key, &err);
|
||||||
|
cleanup_error (&err);
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
if (value->type == GCONF_VALUE_BOOL)
|
||||||
|
{
|
||||||
|
*val = gconf_value_get_bool (value);
|
||||||
|
filled_in = TRUE;
|
||||||
|
}
|
||||||
|
gconf_value_free (value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filled_in;
|
||||||
|
}
|
||||||
#endif /* HAVE_GCONF */
|
#endif /* HAVE_GCONF */
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -350,9 +373,7 @@ meta_prefs_init (void)
|
|||||||
update_focus_mode (str_val);
|
update_focus_mode (str_val);
|
||||||
g_free (str_val);
|
g_free (str_val);
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_RAISE_ON_CLICK,
|
if (get_bool (KEY_RAISE_ON_CLICK, &bool_val))
|
||||||
&err);
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_raise_on_click (bool_val);
|
update_raise_on_click (bool_val);
|
||||||
|
|
||||||
str_val = gconf_client_get_string (default_client,
|
str_val = gconf_client_get_string (default_client,
|
||||||
@ -362,11 +383,15 @@ meta_prefs_init (void)
|
|||||||
update_action_double_click_titlebar (str_val);
|
update_action_double_click_titlebar (str_val);
|
||||||
g_free (str_val);
|
g_free (str_val);
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_AUTO_RAISE,
|
if (get_bool (KEY_AUTO_RAISE, &bool_val))
|
||||||
&err);
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_auto_raise (bool_val);
|
update_auto_raise (bool_val);
|
||||||
|
|
||||||
|
/* FIXME: Since auto_raise_delay of 0 is valid and gconf_client_get_int
|
||||||
|
* silently returns that value when KEY_AUTO_RAISE_DELAY doesn't exist,
|
||||||
|
* we should be using gconf_client_get() instead if we cared about
|
||||||
|
* careful error checking of the key-doesn't-exist case. Since this
|
||||||
|
* setting is crap, though, I'm adding a FIXME instead of fixing it. ;-)
|
||||||
|
*/
|
||||||
int_val = gconf_client_get_int (default_client, KEY_AUTO_RAISE_DELAY,
|
int_val = gconf_client_get_int (default_client, KEY_AUTO_RAISE_DELAY,
|
||||||
&err);
|
&err);
|
||||||
cleanup_error (&err);
|
cleanup_error (&err);
|
||||||
@ -384,9 +409,7 @@ meta_prefs_init (void)
|
|||||||
* just lazy. But they keys ought to be set, anyhow.
|
* just lazy. But they keys ought to be set, anyhow.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_USE_SYSTEM_FONT,
|
if (get_bool (KEY_USE_SYSTEM_FONT, &bool_val))
|
||||||
&err);
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_use_system_font (bool_val);
|
update_use_system_font (bool_val);
|
||||||
|
|
||||||
str_val = gconf_client_get_string (default_client, KEY_TITLEBAR_FONT,
|
str_val = gconf_client_get_string (default_client, KEY_TITLEBAR_FONT,
|
||||||
@ -400,14 +423,10 @@ meta_prefs_init (void)
|
|||||||
cleanup_error (&err);
|
cleanup_error (&err);
|
||||||
update_num_workspaces (int_val);
|
update_num_workspaces (int_val);
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_APPLICATION_BASED,
|
if (get_bool (KEY_APPLICATION_BASED, &bool_val))
|
||||||
&err);
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_application_based (bool_val);
|
update_application_based (bool_val);
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_DISABLE_WORKAROUNDS,
|
if (get_bool (KEY_DISABLE_WORKAROUNDS, &bool_val))
|
||||||
&err);
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_disable_workarounds (bool_val);
|
update_disable_workarounds (bool_val);
|
||||||
|
|
||||||
str_val = gconf_client_get_string (default_client, KEY_BUTTON_LAYOUT,
|
str_val = gconf_client_get_string (default_client, KEY_BUTTON_LAYOUT,
|
||||||
@ -416,12 +435,8 @@ meta_prefs_init (void)
|
|||||||
update_button_layout (str_val);
|
update_button_layout (str_val);
|
||||||
g_free (str_val);
|
g_free (str_val);
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_VISUAL_BELL,
|
if (get_bool (KEY_VISUAL_BELL, &bool_val) ||
|
||||||
&err);
|
get_bool (KEY_AUDIBLE_BELL, &bool_val_2))
|
||||||
cleanup_error (&err);
|
|
||||||
bool_val_2 = gconf_client_get_bool (default_client, KEY_AUDIBLE_BELL,
|
|
||||||
&err);
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_visual_bell (bool_val, bool_val_2);
|
update_visual_bell (bool_val, bool_val_2);
|
||||||
|
|
||||||
str_val = gconf_client_get_string (default_client, KEY_VISUAL_BELL_TYPE,
|
str_val = gconf_client_get_string (default_client, KEY_VISUAL_BELL_TYPE,
|
||||||
@ -430,9 +445,7 @@ meta_prefs_init (void)
|
|||||||
update_visual_bell_type (str_val);
|
update_visual_bell_type (str_val);
|
||||||
g_free (str_val);
|
g_free (str_val);
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_REDUCED_RESOURCES,
|
if (get_bool (KEY_REDUCED_RESOURCES, &bool_val))
|
||||||
&err);
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_reduced_resources (bool_val);
|
update_reduced_resources (bool_val);
|
||||||
|
|
||||||
str_val = gconf_client_get_string (default_client, KEY_TERMINAL_COMMAND,
|
str_val = gconf_client_get_string (default_client, KEY_TERMINAL_COMMAND,
|
||||||
@ -441,10 +454,7 @@ meta_prefs_init (void)
|
|||||||
update_terminal_command (str_val);
|
update_terminal_command (str_val);
|
||||||
g_free (str_val);
|
g_free (str_val);
|
||||||
|
|
||||||
bool_val = gconf_client_get_bool (default_client, KEY_GNOME_ACCESSIBILITY,
|
if (get_bool (KEY_GNOME_ACCESSIBILITY, &bool_val))
|
||||||
&err);
|
|
||||||
|
|
||||||
cleanup_error (&err);
|
|
||||||
update_gnome_accessibility (bool_val);
|
update_gnome_accessibility (bool_val);
|
||||||
|
|
||||||
str_val = gconf_client_get_string (default_client, KEY_CURSOR_THEME,
|
str_val = gconf_client_get_string (default_client, KEY_CURSOR_THEME,
|
||||||
@ -1109,7 +1119,11 @@ update_cursor_size (int value)
|
|||||||
{
|
{
|
||||||
int old = cursor_size;
|
int old = cursor_size;
|
||||||
|
|
||||||
|
if (value >= 1 && value <= 128)
|
||||||
cursor_size = value;
|
cursor_size = value;
|
||||||
|
else
|
||||||
|
meta_warning (_("%d stored in GConf key %s is not a reasonable cursor_size; must be in the range 1..128\n"),
|
||||||
|
value, KEY_CURSOR_SIZE);
|
||||||
|
|
||||||
return old != value;
|
return old != value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user