Commit e105a881 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Check presence GSettingsSchema keys before getting them

The Glib documentation [1] states that "It is a programmer error to
give a key that isn't specified as having a string type in the schema
for settings."  Therefore, we must check if the settings schema has the
key before actually getting any settings. If we do not do this, glib
will terminate chrome with this error message:

  GLib-GIO-ERROR **: Settings schema 'org.cinnamon.muffin' does not
  contain a key named 'button-layout'

Also increase the glib requirement to 2.40 since that's the minimum
version that provides g_settings_schema_has_key.  This version is
available on all supported distros all the way back to Ubuntu Trusty.

[1] https://developer.gnome.org/gio/stable/GSettings.html#g-settings-get-string

BUG=1017974
R=thestig

Change-Id: I46f95bd7a242e48e1d9dc910f6b1f3ed114e7d9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880567
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710152}
parent 3da6c170
......@@ -94,8 +94,8 @@ if (use_glib) {
"gthread-2.0",
]
defines = [
"GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32",
"GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26",
"GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40",
"GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40",
]
}
}
......
......@@ -47,8 +47,10 @@ SettingsProviderGSettings::SettingsProviderGSettings(GtkUi* delegate)
? kCinnamonPreferencesSchema
: kGnomePreferencesSchema;
if (!g_settings_schema_source_lookup(g_settings_schema_source_get_default(),
settings_schema, FALSE) ||
GSettingsSchema* button_schema = g_settings_schema_source_lookup(
g_settings_schema_source_get_default(), settings_schema, FALSE);
if (!button_schema ||
!g_settings_schema_has_key(button_schema, kButtonLayoutKey) ||
!(button_settings_ = g_settings_new(settings_schema))) {
ParseAndStoreButtonValue(kDefaultButtonString);
} else {
......@@ -59,9 +61,11 @@ SettingsProviderGSettings::SettingsProviderGSettings(GtkUi* delegate)
G_CALLBACK(OnDecorationButtonLayoutChangedThunk), this);
}
GSettingsSchema* click_schema = g_settings_schema_source_lookup(
g_settings_schema_source_get_default(), kGnomePreferencesSchema, FALSE);
// If this fails, the default action has already been set in gtk_ui.cc.
if (g_settings_schema_source_lookup(g_settings_schema_source_get_default(),
kGnomePreferencesSchema, FALSE) &&
if (click_schema &&
g_settings_schema_has_key(click_schema, kMiddleClickActionKey) &&
(click_settings_ = g_settings_new(kGnomePreferencesSchema))) {
OnMiddleClickActionChanged(click_settings_, kMiddleClickActionKey);
signal_middle_click_id_ =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment