[GTK] Fix crash when calling g_settings_new()
R=thestig Bug: 405286896 Change-Id: I1a64af5f605355a7fe70fa8e97718ed0eaea2cbc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6409959 Commit-Queue: Lei Zhang <thestig@chromium.org> Commit-Queue: Thomas Anderson <thomasanderson@chromium.org> Auto-Submit: Thomas Anderson <thomasanderson@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#1439828}
This commit is contained in:
parent
a29762124d
commit
d4ee8b67fb
@ -84,7 +84,17 @@ constexpr auto kEmacsBindings =
|
||||
} // namespace
|
||||
|
||||
GtkKeyBindingsHandler::GtkKeyBindingsHandler() {
|
||||
settings_ = TakeGObject(g_settings_new(kDesktopInterface));
|
||||
// g_settings_new() will fatally fail if the schema does not exist, so
|
||||
// use g_settings_schema_source_lookup() to check for it first.
|
||||
auto* schema_source = g_settings_schema_source_get_default();
|
||||
auto* schema =
|
||||
g_settings_schema_source_lookup(schema_source, kDesktopInterface, true);
|
||||
if (!schema) {
|
||||
return;
|
||||
}
|
||||
settings_ = TakeGObject(g_settings_new_full(schema, nullptr, nullptr));
|
||||
g_settings_schema_unref(schema);
|
||||
|
||||
signal_ = ScopedGSignal(
|
||||
settings_, "changed",
|
||||
base::BindRepeating(&GtkKeyBindingsHandler::OnSettingsChanged,
|
||||
|
Loading…
x
Reference in New Issue
Block a user