[gsettings] Avoid crash from settings schema not being registered.

This commit is contained in:
John Ralls 2021-09-28 11:00:05 -07:00
parent c96024ab3d
commit 8bfa5a63f2

View File

@ -101,9 +101,13 @@ static GSettings * gnc_gsettings_get_settings_ptr (const gchar *schema_str)
gset = static_cast<GSettings*> (g_hash_table_lookup (schema_hash, full_name));
DEBUG ("Looking for schema %s returned gsettings %p", full_name, gset);
auto schema_source{g_settings_schema_source_get_default( )};
if (!gset)
{
gset = g_settings_new (full_name);
auto schema_source {g_settings_schema_source_get_default()};
auto schema {g_settings_schema_source_lookup(schema_source, full_name,
FALSE)};
gset = g_settings_new_full (schema, nullptr, nullptr);
DEBUG ("Created gsettings object %p for schema %s", gset, full_name);
if (G_IS_SETTINGS(gset))
g_hash_table_insert (schema_hash, full_name, gset);
@ -114,7 +118,6 @@ static GSettings * gnc_gsettings_get_settings_ptr (const gchar *schema_str)
{
g_free(full_name);
}
LEAVE("");
return gset;
}