From 8bfa5a63f2d9fa80f9985821f61ac289a243e609 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 28 Sep 2021 11:00:05 -0700 Subject: [PATCH] [gsettings] Avoid crash from settings schema not being registered. --- libgnucash/app-utils/gnc-gsettings.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libgnucash/app-utils/gnc-gsettings.cpp b/libgnucash/app-utils/gnc-gsettings.cpp index 9288f6f515..4476d7dc80 100644 --- a/libgnucash/app-utils/gnc-gsettings.cpp +++ b/libgnucash/app-utils/gnc-gsettings.cpp @@ -101,9 +101,13 @@ static GSettings * gnc_gsettings_get_settings_ptr (const gchar *schema_str) gset = static_cast (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; }