summaryrefslogtreecommitdiff
path: root/src/gpm-control.c
diff options
context:
space:
mode:
authorBrent Hull <[email protected]>2012-11-04 00:03:13 -0400
committerBrent Hull <[email protected]>2012-11-04 00:03:13 -0400
commit6e3ef00b551ed8ac5b877f0c7c8ebbc4f7fcb3ff (patch)
tree774710082697e9b466b1f87c311fedbe2e0ce05f /src/gpm-control.c
parent7fa7c26dce5c987539f70b323ae1ff9d40752b0b (diff)
downloadmate-power-manager-6e3ef00b551ed8ac5b877f0c7c8ebbc4f7fcb3ff.tar.bz2
mate-power-manager-6e3ef00b551ed8ac5b877f0c7c8ebbc4f7fcb3ff.tar.xz
Don't depend on mate-screensaver's gschema being installed
Diffstat (limited to 'src/gpm-control.c')
-rw-r--r--src/gpm-control.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/gpm-control.c b/src/gpm-control.c
index d29146f..4b6c959 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -55,7 +55,6 @@
struct GpmControlPrivate
{
GSettings *settings;
- GSettings *settings_ss;
UpClient *client;
};
@@ -116,13 +115,31 @@ gpm_control_get_lock_policy (GpmControl *control, const gchar *policy)
{
gboolean do_lock;
gboolean use_ss_setting;
+ const char * const *schemas;
+ gboolean schema_exists;
+ gint i;
+
+ /* Check if the mate-screensaver schema exists before trying to read
+ the lock setting to prevent crashing. See GNOME bug #651225. */
+ schemas = g_settings_list_schemas ();
+ schema_exists = FALSE;
+ for (i = 0; schemas[i] != NULL; i++) {
+ if (g_strcmp0 (schemas[i], GS_SETTINGS_SCHEMA) == 0) {
+ schema_exists = TRUE;
+ break;
+ }
+ }
+
/* This allows us to over-ride the custom lock settings set
with a system default set in mate-screensaver.
See bug #331164 for all the juicy details. :-) */
use_ss_setting = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_USE_SCREENSAVER);
- if (use_ss_setting) {
- do_lock = g_settings_get_boolean (control->priv->settings_ss, GS_SETTINGS_PREF_LOCK_ENABLED);
+ if (use_ss_setting && schema_exists) {
+ GSettings *settings_ss;
+ settings_ss = g_settings_new (GS_SETTINGS_SCHEMA);
+ do_lock = g_settings_get_boolean (settings_ss, GS_SETTINGS_PREF_LOCK_ENABLED);
egg_debug ("Using ScreenSaver settings (%i)", do_lock);
+ g_object_unref (settings_ss);
} else {
do_lock = g_settings_get_boolean (control->priv->settings, policy);
egg_debug ("Using custom locking settings (%i)", do_lock);
@@ -279,7 +296,6 @@ gpm_control_finalize (GObject *object)
control = GPM_CONTROL (object);
g_object_unref (control->priv->settings);
- g_object_unref (control->priv->settings_ss);
g_object_unref (control->priv->client);
g_return_if_fail (control->priv != NULL);
@@ -328,7 +344,6 @@ gpm_control_init (GpmControl *control)
control->priv->client = up_client_new ();
control->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
- control->priv->settings_ss = g_settings_new (GS_SETTINGS_SCHEMA);
}
/**