From c0eaf88d485d699338d64c97baa38134ca2a0d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Tue, 15 Oct 2024 05:13:16 +0200 Subject: Check the existence of dconf-editor's schema (#1447) We need to check the existence of dconf-editor's GSettings schema before using it, because the program will abort if dconf-editor is not installed on the system when it tries to access it. --- libmate-panel-applet/mate-panel-applet-gsettings.c | 18 ++++++++++++++++-- mate-panel/panel-profile.c | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.c b/libmate-panel-applet/mate-panel-applet-gsettings.c index 82867639..93d0b4ce 100644 --- a/libmate-panel-applet/mate-panel-applet-gsettings.c +++ b/libmate-panel-applet/mate-panel-applet-gsettings.c @@ -90,8 +90,21 @@ add_to_dict (GVariant *dict, const gchar *schema, const gchar *path) static void register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path) { - GSettings *dconf_editor_settings; - dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings"); + GSettingsSchemaSource *source; + GSettingsSchema *dconf_editor_schema; + GSettings *dconf_editor_settings; + + source = g_settings_schema_source_get_default (); + + if (! source) + return; + + dconf_editor_schema = g_settings_schema_source_lookup (source, "ca.desrt.dconf-editor.Settings", FALSE); + + if (! dconf_editor_schema) + return; + + dconf_editor_settings = g_settings_new_full (dconf_editor_schema, NULL, NULL); if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) { GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths"); @@ -108,6 +121,7 @@ register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path } g_object_unref (dconf_editor_settings); + g_settings_schema_unref (dconf_editor_schema); } GSettings * diff --git a/mate-panel/panel-profile.c b/mate-panel/panel-profile.c index b637563a..ac08fc16 100644 --- a/mate-panel/panel-profile.c +++ b/mate-panel/panel-profile.c @@ -862,8 +862,21 @@ remove_from_dict (GVariant *dict, const gchar *path) static void unregister_dconf_editor_relocatable_schema (const gchar *path) { - GSettings *dconf_editor_settings; - dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings"); + GSettingsSchemaSource *source; + GSettingsSchema *dconf_editor_schema; + GSettings *dconf_editor_settings; + + source = g_settings_schema_source_get_default (); + + if (! source) + return; + + dconf_editor_schema = g_settings_schema_source_lookup (source, "ca.desrt.dconf-editor.Settings", FALSE); + + if (! dconf_editor_schema) + return; + + dconf_editor_settings = g_settings_new_full (dconf_editor_schema, NULL, NULL); if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) { GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths"); @@ -878,6 +891,7 @@ unregister_dconf_editor_relocatable_schema (const gchar *path) } g_object_unref (dconf_editor_settings); + g_settings_schema_unref (dconf_editor_schema); } -- cgit v1.2.1