[libhandy/wip/exalm/alpha-fixes: 2/8] settings: Fix a GSettingsSchema leak




commit a051556fec08e159573231242660f539614942fe
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Oct 5 20:42:01 2021 +0100

    settings: Fix a GSettingsSchema leak
    
    `g_settings_schema_source_lookup()` returns a new reference.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Backported from 
https://gitlab.gnome.org/GNOME/libadwaita/-/commit/18a1d426e7a7dc1034c0012a14ca31e73fe266a0

 src/hdy-settings.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/hdy-settings.c b/src/hdy-settings.c
index 0d8d57a7..03a9d72e 100644
--- a/src/hdy-settings.c
+++ b/src/hdy-settings.c
@@ -296,7 +296,8 @@ static void
 init_gsettings (HdySettings *self)
 {
   GSettingsSchemaSource *source;
-  GSettingsSchema *schema;
+  g_autoptr (GSettingsSchema) schema = NULL;
+  g_autoptr (GSettingsSchema) a11y_schema = NULL;
 
   /* While we can access gsettings in flatpak, we can't do anything useful with
    * them as they aren't propagated from the system. */
@@ -319,10 +320,10 @@ init_gsettings (HdySettings *self)
                               self);
   }
 
-  schema = g_settings_schema_source_lookup (source, "org.gnome.desktop.a11y.interface", TRUE);
-  if (schema &&
+  a11y_schema = g_settings_schema_source_lookup (source, "org.gnome.desktop.a11y.interface", TRUE);
+  if (a11y_schema &&
       !self->has_high_contrast &&
-      g_settings_schema_has_key (schema, "high-contrast")) {
+      g_settings_schema_has_key (a11y_schema, "high-contrast")) {
     self->has_high_contrast = TRUE;
     self->a11y_settings = g_settings_new ("org.gnome.desktop.a11y.interface");
     self->high_contrast = g_settings_get_boolean (self->a11y_settings, "high-contrast");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]