From 3212519b44786184c2753597cab30d89395e735e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 8 Oct 2011 15:49:58 -0400 Subject: Error gracefully if we can't get our settings. --- src/settings-helper.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/settings-helper.c') diff --git a/src/settings-helper.c b/src/settings-helper.c index d70df95..b8f482f 100644 --- a/src/settings-helper.c +++ b/src/settings-helper.c @@ -38,41 +38,44 @@ static guint logout_notify = 0; static guint restart_notify = 0; static guint shutdown_notify = 0; -static void +static gboolean build_settings (void) { - if(!settings) { + if (settings == NULL) { settings = g_settings_new (SESSION_SCHEMA); } - return; + if (settings == NULL) { + return FALSE; + } + return TRUE; } gboolean supress_confirmations (void) { - build_settings(); + g_return_val_if_fail(build_settings(), FALSE); return g_settings_get_boolean (settings, SUPPRESS_KEY) ; } gboolean should_show_user_menu (void) { - build_settings(); + g_return_val_if_fail(build_settings(), TRUE); return g_settings_get_boolean (settings, SHOW_USER_MENU) ; } gboolean show_logout (void) { - build_settings(); + g_return_val_if_fail(build_settings(), TRUE); return !g_settings_get_boolean (settings, LOGOUT_KEY) ; } gboolean show_restart (void) { - build_settings(); + g_return_val_if_fail(build_settings(), TRUE); return !g_settings_get_boolean (settings, RESTART_KEY) ; } gboolean show_shutdown (void) { - build_settings(); + g_return_val_if_fail(build_settings(), TRUE); return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ; } @@ -122,7 +125,7 @@ update_shutdown_callback (GSettings * settings, const gchar * key, gpointer data void update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { /* If we don't have a client, build one. */ - build_settings(); + g_return_if_fail(build_settings()); if (confirmation_notify != 0) { g_signal_handler_disconnect (settings, confirmation_notify); -- cgit v1.2.3 From c20ca2c4b4c096b12d7d5a0b7df401dfb9f9f500 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 10 Oct 2011 16:45:48 -0400 Subject: Use a temporary variable to defeat G_DISABLE_CHECKS --- src/settings-helper.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/settings-helper.c') diff --git a/src/settings-helper.c b/src/settings-helper.c index b8f482f..55411da 100644 --- a/src/settings-helper.c +++ b/src/settings-helper.c @@ -51,31 +51,36 @@ build_settings (void) { gboolean supress_confirmations (void) { - g_return_val_if_fail(build_settings(), FALSE); + gboolean settings_built = build_settings(); + g_return_val_if_fail(settings_built, FALSE); return g_settings_get_boolean (settings, SUPPRESS_KEY) ; } gboolean should_show_user_menu (void) { - g_return_val_if_fail(build_settings(), TRUE); + gboolean settings_built = build_settings(); + g_return_val_if_fail(settings_built, TRUE); return g_settings_get_boolean (settings, SHOW_USER_MENU) ; } gboolean show_logout (void) { - g_return_val_if_fail(build_settings(), TRUE); + gboolean settings_built = build_settings(); + g_return_val_if_fail(settings_built, TRUE); return !g_settings_get_boolean (settings, LOGOUT_KEY) ; } gboolean show_restart (void) { - g_return_val_if_fail(build_settings(), TRUE); + gboolean settings_built = build_settings(); + g_return_val_if_fail(settings_built, TRUE); return !g_settings_get_boolean (settings, RESTART_KEY) ; } gboolean show_shutdown (void) { - g_return_val_if_fail(build_settings(), TRUE); + gboolean settings_built = build_settings(); + g_return_val_if_fail(settings_built, TRUE); return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ; } -- cgit v1.2.3 From 2e2cf84cd5e3c6791c5684032e014fc74da09424 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 12 Oct 2011 15:30:18 -0500 Subject: Okay, get all of them I guess --- src/settings-helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/settings-helper.c') diff --git a/src/settings-helper.c b/src/settings-helper.c index 55411da..007f83f 100644 --- a/src/settings-helper.c +++ b/src/settings-helper.c @@ -130,7 +130,8 @@ update_shutdown_callback (GSettings * settings, const gchar * key, gpointer data void update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { /* If we don't have a client, build one. */ - g_return_if_fail(build_settings()); + gboolean settings_built = build_settings(); + g_return_if_fail(settings_built); if (confirmation_notify != 0) { g_signal_handler_disconnect (settings, confirmation_notify); -- cgit v1.2.3