[libadwaita/msvc: 84/88] src: Remove g_auto* usage




commit 04394483a0868518a99490040806c500b018d5fc
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jul 26 18:58:32 2021 +0800

    src: Remove g_auto* usage
    
    It is unfortunately a GCCism, so use the traditional method instead.
    Unfortunately the autocleanup compiler extensions are not standard across the
    board.

 src/adw-application.c              |  6 ++-
 src/adw-avatar.c                   | 30 ++++++++++-----
 src/adw-carousel-indicator-dots.c  |  6 ++-
 src/adw-carousel-indicator-lines.c | 11 ++++--
 src/adw-combo-row.c                | 12 ++++--
 src/adw-fading-label.c             |  7 +++-
 src/adw-indicator-bin.c            |  8 +++-
 src/adw-preferences-window.c       | 41 +++++++++++++-------
 src/adw-settings.c                 | 78 +++++++++++++++++++++-----------------
 src/adw-style-manager.c            |  3 +-
 src/adw-swipe-tracker.c            | 15 ++++++--
 src/adw-tab-box.c                  |  3 +-
 src/adw-tab-view.c                 |  4 +-
 src/adw-tab.c                      |  3 +-
 src/adw-view-switcher.c            |  6 ++-
 15 files changed, 150 insertions(+), 83 deletions(-)
---
diff --git a/src/adw-application.c b/src/adw-application.c
index caa7edae..136e240c 100644
--- a/src/adw-application.c
+++ b/src/adw-application.c
@@ -113,8 +113,8 @@ init_providers (AdwApplication *self)
   AdwApplicationPrivate *priv = adw_application_get_instance_private (self);
 
   const char *base_path = NULL;
-  g_autofree char *base_uri = NULL;
-  g_autoptr (GFile) base_file = NULL;
+  char *base_uri = NULL;
+  GFile *base_file = NULL;
 
   base_path = g_application_get_resource_base_path (G_APPLICATION (self));
 
@@ -132,6 +132,8 @@ init_providers (AdwApplication *self)
                            g_file_get_child (base_file, "style-hc.css"));
   init_provider_from_file (&priv->hc_dark_style_provider,
                            g_file_get_child (base_file, "style-hc-dark.css"));
+  g_object_unref (base_file);
+  g_free (base_uri);
 }
 
 static void
diff --git a/src/adw-avatar.c b/src/adw-avatar.c
index 34ece640..1b645c05 100644
--- a/src/adw-avatar.c
+++ b/src/adw-avatar.c
@@ -75,13 +75,16 @@ static char *
 extract_initials_from_text (const char *text)
 {
   GString *initials;
-  g_autofree char *p = g_utf8_strup (text, -1);
-  g_autofree char *normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
+  char *p = g_utf8_strup (text, -1);
+  char *normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
   gunichar unichar;
   char *q = NULL;
 
   if (normalized == NULL)
-    return NULL;
+    {
+      g_free (p);
+      return NULL;
+    }
 
   initials = g_string_new ("");
 
@@ -96,6 +99,8 @@ extract_initials_from_text (const char *text)
     g_string_append_unichar (initials, unichar);
   }
 
+  g_free (normalized);
+  g_free (p);
   return g_string_free (initials, FALSE);
 }
 
@@ -113,9 +118,9 @@ update_visibility (AdwAvatar *self)
 static void
 set_class_color (AdwAvatar *self)
 {
-  g_autofree GRand *rand = NULL;
-  g_autofree char *new_class = NULL;
-  g_autofree char *old_class = g_strdup_printf ("color%d", self->color_class);
+  GRand *rand = NULL;
+  char *new_class = NULL;
+  char *old_class = g_strdup_printf ("color%d", self->color_class);
 
   gtk_widget_remove_css_class (self->gizmo, old_class);
 
@@ -123,6 +128,7 @@ set_class_color (AdwAvatar *self)
     /* Use a random color if we don't have a text */
     rand = g_rand_new ();
     self->color_class = g_rand_int_range (rand, 1, NUMBER_OF_COLORS);
+    g_rand_free (rand);
   } else {
     self->color_class = (g_str_hash (self->text) % NUMBER_OF_COLORS) + 1;
   }
@@ -130,12 +136,14 @@ set_class_color (AdwAvatar *self)
   new_class = g_strdup_printf ("color%d", self->color_class);
 
   gtk_widget_add_css_class (self->gizmo, new_class);
+  g_free (new_class);
+  g_free (old_class);
 }
 
 static void
 update_initials (AdwAvatar *self)
 {
-  g_autofree char *initials = NULL;
+  char *initials = NULL;
 
   if (gtk_image_get_paintable (self->custom_image) != NULL ||
       !self->show_initials ||
@@ -146,6 +154,7 @@ update_initials (AdwAvatar *self)
   initials = extract_initials_from_text (self->text);
 
   gtk_label_set_label (self->label, initials);
+  g_free (initials);
 }
 
 static void
@@ -696,7 +705,8 @@ GdkTexture *
 adw_avatar_draw_to_texture (AdwAvatar *self,
                             int        scale_factor)
 {
-  g_autoptr (GskRenderNode) node = NULL;
+  GdkTexture *result = NULL;
+  GskRenderNode *node = NULL;
   GtkSnapshot *snapshot;
   GtkNative *native;
   GskRenderer *renderer;
@@ -716,5 +726,7 @@ adw_avatar_draw_to_texture (AdwAvatar *self,
   native = gtk_widget_get_native (GTK_WIDGET (self));
   renderer = gtk_native_get_renderer (native);
 
-  return gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, size, size));
+  result = gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, size, size));
+  gsk_render_node_unref (node);
+  return result;
 }
diff --git a/src/adw-carousel-indicator-dots.c b/src/adw-carousel-indicator-dots.c
index 99d1e085..bfb49e48 100644
--- a/src/adw-carousel-indicator-dots.c
+++ b/src/adw-carousel-indicator-dots.c
@@ -244,8 +244,8 @@ adw_carousel_indicator_dots_snapshot (GtkWidget   *widget,
   AdwCarouselIndicatorDots *self = ADW_CAROUSEL_INDICATOR_DOTS (widget);
   int i, n_points;
   double position;
-  g_autofree double *points = NULL;
-  g_autofree double *sizes = NULL;
+  double *points = NULL;
+  double *sizes = NULL;
 
   if (!self->carousel)
     return;
@@ -267,6 +267,8 @@ adw_carousel_indicator_dots_snapshot (GtkWidget   *widget,
     sizes[i] = points[i] - points[i - 1];
 
   snapshot_dots (widget, snapshot, self->orientation, position, sizes, n_points);
+  g_free (sizes);
+  g_free (points);
 }
 
 static void
diff --git a/src/adw-carousel-indicator-lines.c b/src/adw-carousel-indicator-lines.c
index 5095768e..3dd5ac90 100644
--- a/src/adw-carousel-indicator-lines.c
+++ b/src/adw-carousel-indicator-lines.c
@@ -229,8 +229,8 @@ adw_carousel_indicator_lines_snapshot (GtkWidget   *widget,
   AdwCarouselIndicatorLines *self = ADW_CAROUSEL_INDICATOR_LINES (widget);
   int i, n_points;
   double position;
-  g_autofree double *points = NULL;
-  g_autofree double *sizes = NULL;
+  double *points = NULL;
+  double *sizes = NULL;
 
   if (!self->carousel)
     return;
@@ -239,7 +239,10 @@ adw_carousel_indicator_lines_snapshot (GtkWidget   *widget,
   position = adw_carousel_get_position (self->carousel);
 
   if (n_points < 2)
-    return;
+    {
+      g_free (points);
+      return;
+    }    
 
   if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
       gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
@@ -252,6 +255,8 @@ adw_carousel_indicator_lines_snapshot (GtkWidget   *widget,
     sizes[i] = points[i] - points[i - 1];
 
   snapshot_lines (widget, snapshot, self->orientation, position, sizes, n_points);
+  g_free (sizes);
+  g_free (points);
 }
 
 static void
diff --git a/src/adw-combo-row.c b/src/adw-combo-row.c
index 7942c549..af7960de 100644
--- a/src/adw-combo-row.c
+++ b/src/adw-combo-row.c
@@ -114,10 +114,12 @@ selection_changed (AdwComboRow *self)
 
   if (priv->use_subtitle) {
     if (g_list_model_get_n_items (G_LIST_MODEL (priv->current_selection)) > 0) {
-      g_autoptr (GtkListItem) item = g_list_model_get_item (G_LIST_MODEL (priv->current_selection), 0);
-      g_autofree char *repr = get_item_representation (self, item);
+      GtkListItem *item = g_list_model_get_item (G_LIST_MODEL (priv->current_selection), 0);
+      char *repr = get_item_representation (self, item);
 
       adw_action_row_set_subtitle (ADW_ACTION_ROW (self), repr);
+      g_free (repr);
+      g_object_unref (item);
     } else {
       adw_action_row_set_subtitle (ADW_ACTION_ROW (self), NULL);
     }
@@ -222,7 +224,7 @@ bind_item (GtkSignalListItemFactory *factory,
   gpointer item;
   GtkWidget *box;
   GtkWidget *icon;
-  g_autofree char *repr = NULL;
+  char *repr = NULL;
 
   item = gtk_list_item_get_item (list_item);
   box = gtk_list_item_get_child (list_item);
@@ -234,6 +236,7 @@ bind_item (GtkSignalListItemFactory *factory,
     GtkWidget *label = gtk_widget_get_first_child (box);
 
     gtk_label_set_label (GTK_LABEL (label), repr);
+    g_free (repr);
   } else {
     g_critical ("Either AdwComboRow:factory or AdwComboRow:expression must be set");
   }
@@ -259,13 +262,14 @@ unbind_item (GtkSignalListItemFactory *factory,
 static void
 set_default_factory (AdwComboRow *self)
 {
-  g_autoptr (GtkListItemFactory) factory = gtk_signal_list_item_factory_new ();
+  GtkListItemFactory *factory = gtk_signal_list_item_factory_new ();
 
   g_signal_connect (factory, "setup", G_CALLBACK (setup_item), self);
   g_signal_connect (factory, "bind", G_CALLBACK (bind_item), self);
   g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item), self);
 
   adw_combo_row_set_factory (self, factory);
+  g_object_unref (factory);
 }
 
 static void
diff --git a/src/adw-fading-label.c b/src/adw-fading-label.c
index f903ac46..f1408335 100644
--- a/src/adw-fading-label.c
+++ b/src/adw-fading-label.c
@@ -59,7 +59,7 @@ ensure_shader (AdwFadingLabel *self)
 {
   GtkNative *native;
   GskRenderer *renderer;
-  g_autoptr (GError) error = NULL;
+  GError *error = NULL;
 
   if (self->shader)
     return;
@@ -76,6 +76,8 @@ ensure_shader (AdwFadingLabel *self)
      * silently fall back */
     if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
       g_critical ("Couldn't compile shader: %s\n", error->message);
+
+    g_clear_error (&error);
   }
 }
 
@@ -127,7 +129,7 @@ adw_fading_label_snapshot (GtkWidget   *widget,
   int width = gtk_widget_get_width (widget);
   int clipped_size;
   GtkSnapshot *child_snapshot;
-  g_autoptr (GskRenderNode) node = NULL;
+  GskRenderNode *node = NULL;
   graphene_rect_t bounds;
 
   if (width <= 0)
@@ -169,6 +171,7 @@ adw_fading_label_snapshot (GtkWidget   *widget,
     gtk_snapshot_gl_shader_pop_texture (snapshot);
 
   gtk_snapshot_pop (snapshot);
+  gsk_render_node_unref (node);
 }
 
 static void
diff --git a/src/adw-indicator-bin.c b/src/adw-indicator-bin.c
index 3e60d67e..98b9dc08 100644
--- a/src/adw-indicator-bin.c
+++ b/src/adw-indicator-bin.c
@@ -61,7 +61,7 @@ ensure_shader (AdwIndicatorBin *self)
 {
   GtkNative *native;
   GskRenderer *renderer;
-  g_autoptr (GError) error = NULL;
+  GError *error = NULL;
 
   if (self->shader)
     return;
@@ -78,6 +78,8 @@ ensure_shader (AdwIndicatorBin *self)
      * silently fall back */
     if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
       g_critical ("Couldn't compile shader: %s\n", error->message);
+
+    g_clear_error (&error);
   }
 }
 
@@ -162,7 +164,7 @@ adw_indicator_bin_snapshot (GtkWidget   *widget,
 
   if (self->child) {
     GtkSnapshot *child_snapshot;
-    g_autoptr (GskRenderNode) child_node = NULL;
+    GskRenderNode *child_node = NULL;
 
     child_snapshot = gtk_snapshot_new ();
     gtk_widget_snapshot_child (widget, self->child, child_snapshot);
@@ -188,6 +190,8 @@ adw_indicator_bin_snapshot (GtkWidget   *widget,
 
       gtk_snapshot_pop (snapshot);
     }
+
+    gsk_render_node_unref (child_node);
   }
 
   gtk_widget_snapshot_child (widget, self->indicator, snapshot);
diff --git a/src/adw-preferences-window.c b/src/adw-preferences-window.c
index 8d81dd3a..e18f9036 100644
--- a/src/adw-preferences-window.c
+++ b/src/adw-preferences-window.c
@@ -82,7 +82,7 @@ static GParamSpec *props[LAST_PROP];
 static char *
 strip_mnemonic (const char *src)
 {
-  g_autofree char *new_str = g_new (char, strlen (src) + 1);
+  char *new_str = g_new (char, strlen (src) + 1);
   char *dest = new_str;
   gboolean underscore = FALSE;
 
@@ -94,6 +94,7 @@ strip_mnemonic (const char *src)
     if (c == (gunichar) -1) {
       g_warning ("Invalid input string");
 
+      g_free (new_str);
       return NULL;
     }
 
@@ -125,8 +126,9 @@ filter_search_results (AdwPreferencesRow    *row,
                        AdwPreferencesWindow *self)
 {
   AdwPreferencesWindowPrivate *priv = adw_preferences_window_get_instance_private (self);
-  g_autofree char *terms = NULL;
-  g_autofree char *title = NULL;
+  char *terms = NULL;
+  char *title = NULL;
+  gboolean result = FALSE;
 
   g_assert (ADW_IS_PREFERENCES_ROW (row));
 
@@ -143,16 +145,20 @@ filter_search_results (AdwPreferencesRow    *row,
   }
 
   if (!!strstr (title, terms))
-    return TRUE;
+    result = TRUE;
 
-  if (ADW_IS_ACTION_ROW (row)) {
-    g_autofree char *subtitle = g_utf8_casefold (adw_action_row_get_subtitle (ADW_ACTION_ROW (row)), -1);
+  else if (ADW_IS_ACTION_ROW (row)) {
+    char *subtitle = g_utf8_casefold (adw_action_row_get_subtitle (ADW_ACTION_ROW (row)), -1);
 
     if (!!strstr (subtitle, terms))
-      return TRUE;
+      result = TRUE;
+
+    g_free (subtitle);
   }
 
-  return FALSE;
+  g_free (title);
+  g_free (terms);
+  return result;
 }
 
 static int
@@ -180,7 +186,7 @@ create_search_row_subtitle (AdwPreferencesWindow *self,
 {
   GtkWidget *group, *page;
   const char *group_title = NULL;
-  g_autofree char *page_title = NULL;
+  char *page_title = NULL;
 
   group = gtk_widget_get_ancestor (row, ADW_TYPE_PREFERENCES_GROUP);
 
@@ -202,14 +208,22 @@ create_search_row_subtitle (AdwPreferencesWindow *self,
       page_title = g_strdup (title);
 
     if (g_strcmp0 (page_title, "") == 0)
-      page_title = NULL;
+      {
+        g_free (page_title);
+        page_title = NULL;
+      }
   }
 
   if (group_title) {
+    gchar *result = NULL;
+
     if (get_n_pages (self) > 1)
-      return g_strdup_printf ("%s → %s", page_title ? page_title : _("Untitled page"), group_title);
+      result = g_strdup_printf ("%s → %s", page_title ? page_title : _("Untitled page"), group_title);
+    else
+      result = g_strdup (group_title);
 
-    return g_strdup (group_title);
+    g_free (page_title);
+    return result;
   }
 
   if (page_title)
@@ -224,7 +238,7 @@ new_search_row_for_preference (AdwPreferencesRow    *row,
 {
   AdwActionRow *widget;
   GtkWidget *page;
-  g_autofree char *subtitle = NULL;
+  char *subtitle = NULL;
 
   g_assert (ADW_IS_PREFERENCES_ROW (row));
 
@@ -236,6 +250,7 @@ new_search_row_for_preference (AdwPreferencesRow    *row,
   g_object_bind_property (row, "title", widget, "title", G_BINDING_SYNC_CREATE);
   g_object_bind_property (row, "use-underline", widget, "use-underline", G_BINDING_SYNC_CREATE);
   adw_action_row_set_subtitle (widget, subtitle);
+  g_free (subtitle);
 
   g_object_set_data (G_OBJECT (widget), "page", page);
   g_object_set_data (G_OBJECT (widget), "row", row);
diff --git a/src/adw-settings.c b/src/adw-settings.c
index 80f9b135..e2f3f74b 100644
--- a/src/adw-settings.c
+++ b/src/adw-settings.c
@@ -97,11 +97,12 @@ read_portal_setting (AdwSettings  *self,
                      const char   *type,
                      GVariant    **out)
 {
-  g_autoptr (GError) error = NULL;
-  g_autoptr (GVariant) ret = NULL;
-  g_autoptr (GVariant) child = NULL;
-  g_autoptr (GVariant) child2 = NULL;
-  g_autoptr (GVariantType) out_type = NULL;
+  GError *error = NULL;
+  GVariant *ret = NULL;
+  GVariant *child = NULL;
+  GVariant *child2 = NULL;
+  GVariantType *out_type = NULL;
+  gboolean result;
 
   ret = g_dbus_proxy_call_sync (self->settings_portal,
                                 "Read",
@@ -111,32 +112,30 @@ read_portal_setting (AdwSettings  *self,
                                 NULL,
                                 &error);
   if (error) {
+
     if (error->domain == G_DBUS_ERROR &&
         error->code == G_DBUS_ERROR_SERVICE_UNKNOWN) {
       g_debug ("Portal not found: %s", error->message);
-
-      return FALSE;
     }
 
-    if (error->domain == G_DBUS_ERROR &&
+    else if (error->domain == G_DBUS_ERROR &&
         error->code == G_DBUS_ERROR_UNKNOWN_METHOD) {
       g_debug ("Portal doesn't provide settings: %s", error->message);
-
-      return FALSE;
     }
 
-    if (g_dbus_error_is_remote_error (error)) {
-      g_autofree char *remote_error = g_dbus_error_get_remote_error (error);
+    else if (g_dbus_error_is_remote_error (error)) {
+      char *remote_error = g_dbus_error_get_remote_error (error);
 
       if (!g_strcmp0 (remote_error, PORTAL_ERROR_NOT_FOUND)) {
         g_debug ("Setting %s.%s of type %s not found", schema, name, type);
-
-        return FALSE;
       }
+      g_free (remote_error);
     }
 
-    g_critical ("Couldn't read the %s setting: %s", name, error->message);
+    else
+      g_critical ("Couldn't read the %s setting: %s", name, error->message);
 
+    g_error_free (error);
     return FALSE;
   }
 
@@ -147,13 +146,18 @@ read_portal_setting (AdwSettings  *self,
   if (!g_variant_type_equal (g_variant_get_type (child2), out_type)) {
     g_critical ("Invalid type for %s.%s: expected %s, got %s",
                 schema, name, type, g_variant_get_type_string (child2));
-
-    return FALSE;
+    result = FALSE;
+    g_variant_unref (child2);
+  }
+  else {
+    *out = g_steal_pointer (&child2);
+       result = TRUE;
   }
 
-  *out = g_steal_pointer (&child2);
-
-  return TRUE;
+  g_variant_type_free (out_type);
+  g_variant_unref (child);
+  g_variant_unref (ret);
+  return result;
 }
 
 static AdwSystemColorScheme
@@ -198,7 +202,7 @@ settings_portal_changed_cb (GDBusProxy  *proxy,
 {
   const char *namespace;
   const char *name;
-  g_autoptr (GVariant) value = NULL;
+  GVariant *value = NULL;
 
   if (g_strcmp0 (signal_name, "SettingChanged"))
     return;
@@ -209,32 +213,28 @@ settings_portal_changed_cb (GDBusProxy  *proxy,
       !g_strcmp0 (name, "color-scheme") &&
       self->color_scheme_use_fdo_setting) {
     set_color_scheme (self, get_fdo_color_scheme (value));
-
-    return;
   }
 
-  if (!g_strcmp0 (namespace, "org.gnome.desktop.interface") &&
+  else if (!g_strcmp0 (namespace, "org.gnome.desktop.interface") &&
       !g_strcmp0 (name, "color-scheme") &&
       !self->color_scheme_use_fdo_setting) {
     set_color_scheme (self, get_gnome_color_scheme (value));
-
-    return;
   }
 
-  if (!g_strcmp0 (namespace, "org.gnome.desktop.interface.a11y") &&
+  else if (!g_strcmp0 (namespace, "org.gnome.desktop.interface.a11y") &&
       !g_strcmp0 (name, "high-contrast")) {
     set_high_contrast (self, g_variant_get_boolean (value));
-
-    return;
   }
+  else
+    g_variant_unref (value);
 }
 
 static void
 init_portal (AdwSettings *self)
 {
-  g_autoptr (GError) error = NULL;
-  g_autoptr (GVariant) color_scheme_variant = NULL;
-  g_autoptr (GVariant) high_contrast_variant = NULL;
+  GError *error = NULL;
+  GVariant *color_scheme_variant = NULL;
+  GVariant *high_contrast_variant = NULL;
 
   if (get_disable_portal ())
     return;
@@ -250,6 +250,7 @@ init_portal (AdwSettings *self)
   if (error) {
     g_debug ("Settings portal not found: %s", error->message);
 
+    g_error_free (error);
     return;
   }
 
@@ -258,6 +259,7 @@ init_portal (AdwSettings *self)
     self->has_color_scheme = TRUE;
     self->color_scheme_use_fdo_setting = TRUE;
     self->color_scheme = get_fdo_color_scheme (color_scheme_variant);
+    g_variant_unref (color_scheme_variant);
   }
 
   if (!self->has_color_scheme &&
@@ -265,12 +267,14 @@ init_portal (AdwSettings *self)
                            "color-scheme", "s", &color_scheme_variant)) {
     self->has_color_scheme = TRUE;
     self->color_scheme = get_gnome_color_scheme (color_scheme_variant);
+    g_variant_unref (color_scheme_variant);
   }
 
   if (read_portal_setting (self, "org.gnome.desktop.interface.a11y",
                            "high-contrast", "b", &high_contrast_variant)) {
     self->has_high_contrast = TRUE;
     self->high_contrast = g_variant_get_boolean (high_contrast_variant);
+    g_variant_unref (high_contrast_variant);
   }
 
   if (!self->has_color_scheme && !self->has_high_contrast)
@@ -304,8 +308,8 @@ static void
 init_gsettings (AdwSettings *self)
 {
   GSettingsSchemaSource *source;
-  g_autoptr (GSettingsSchema) schema = NULL;
-  g_autoptr (GSettingsSchema) a11y_schema = NULL;
+  GSettingsSchema *schema = NULL;
+  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. */
@@ -326,6 +330,7 @@ init_gsettings (AdwSettings *self)
                               "changed::color-scheme",
                               G_CALLBACK (gsettings_color_scheme_changed_cb),
                               self);
+    g_settings_schema_unref (schema);
   }
 
   a11y_schema = g_settings_schema_source_lookup (source, "org.gnome.desktop.a11y.interface", TRUE);
@@ -340,6 +345,7 @@ init_gsettings (AdwSettings *self)
                               "changed::high-contrast",
                               G_CALLBACK (gsettings_high_contrast_changed_cb),
                               self);
+    g_settings_schema_unref (a11y_schema);
   }
 }
 
@@ -348,14 +354,16 @@ init_gsettings (AdwSettings *self)
 static gboolean
 is_theme_high_contrast (GdkDisplay *display)
 {
-  g_auto (GValue) value = G_VALUE_INIT;
+  GValue value = G_VALUE_INIT;
   const char *theme_name;
+  gboolean result;
 
   g_value_init (&value, G_TYPE_STRING);
   if (!gdk_display_get_setting (display, "gtk-theme-name", &value))
     return FALSE;
 
   theme_name = g_value_get_string (&value);
+  g_value_unset (&value);
 
   return !g_strcmp0 (theme_name, "HighContrast") ||
          !g_strcmp0 (theme_name, "HighContrastInverse");
diff --git a/src/adw-style-manager.c b/src/adw-style-manager.c
index f9d79144..9d432d9c 100644
--- a/src/adw-style-manager.c
+++ b/src/adw-style-manager.c
@@ -498,7 +498,7 @@ void
 adw_style_manager_ensure (void)
 {
   GdkDisplayManager *display_manager = gdk_display_manager_get ();
-  g_autoptr (GSList) displays = NULL;
+  GSList *displays = NULL;
   GSList *l;
 
   if (display_style_managers)
@@ -515,6 +515,7 @@ adw_style_manager_ensure (void)
   for (l = displays; l; l = l->next)
     register_display (display_manager, l->data);
 
+  g_slist_free (displays);
   g_signal_connect (display_manager,
                     "display-opened",
                     G_CALLBACK (register_display),
diff --git a/src/adw-swipe-tracker.c b/src/adw-swipe-tracker.c
index 418f49cd..55056f8e 100644
--- a/src/adw-swipe-tracker.c
+++ b/src/adw-swipe-tracker.c
@@ -137,13 +137,14 @@ get_range (AdwSwipeTracker *self,
            double          *first,
            double          *last)
 {
-  g_autofree double *points = NULL;
+  double *points = NULL;
   int n;
 
   points = adw_swipeable_get_snap_points (self->swipeable, &n);
 
   *first = points[0];
   *last = points[n - 1];
+  g_free (points);
 }
 
 static void
@@ -321,11 +322,12 @@ gesture_update (AdwSwipeTracker *self,
     return;
 
   if (!self->allow_long_swipes) {
-    g_autofree double *points = NULL;
+    double *points = NULL;
     int n;
 
     points = adw_swipeable_get_snap_points (self->swipeable, &n);
     get_bounds (self, points, n, self->initial_progress, &lower, &upper);
+    g_free (points);
   } else {
     get_range (self, &lower, &upper);
   }
@@ -344,7 +346,7 @@ get_end_progress (AdwSwipeTracker *self,
                   gboolean         is_touchpad)
 {
   double pos, decel, slope;
-  g_autofree double *points = NULL;
+  double *points = NULL;
   int n;
   double lower, upper;
 
@@ -354,7 +356,11 @@ get_end_progress (AdwSwipeTracker *self,
   points = adw_swipeable_get_snap_points (self->swipeable, &n);
 
   if (ABS (velocity) < (is_touchpad ? VELOCITY_THRESHOLD_TOUCHPAD : VELOCITY_THRESHOLD_TOUCH))
-    return points[find_closest_point (points, n, self->progress)];
+    {
+      pos = points[find_closest_point (points, n, self->progress)];
+      g_free (points);
+      return pos;
+    }
 
   decel = is_touchpad ? DECELERATION_TOUCHPAD : DECELERATION_TOUCH;
   slope = decel / (1.0 - decel) / 1000.0;
@@ -382,6 +388,7 @@ get_end_progress (AdwSwipeTracker *self,
   pos = CLAMP (pos, lower, upper);
   pos = points[find_point_for_projection (self, points, n, pos, velocity)];
 
+  g_free (points);
   return pos;
 }
 
diff --git a/src/adw-tab-box.c b/src/adw-tab-box.c
index af6fc84f..37f413b7 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -1825,7 +1825,7 @@ adw_tab_box_root_content_write_mime_type_async (GdkContentProvider  *provider,
                                                 gpointer             user_data)
 {
   AdwTabBoxRootContent *self = ADW_TAB_BOX_ROOT_CONTENT (provider);
-  g_autoptr (GTask) task = NULL;
+  GTask *task = NULL;
 
   self->tab_box->should_detach_into_new_window = TRUE;
 
@@ -1833,6 +1833,7 @@ adw_tab_box_root_content_write_mime_type_async (GdkContentProvider  *provider,
   g_task_set_priority (task, io_priority);
   g_task_set_source_tag (task, adw_tab_box_root_content_write_mime_type_async);
   g_task_return_boolean (task, TRUE);
+  g_object_unref (task);
 }
 
 static gboolean
diff --git a/src/adw-tab-view.c b/src/adw-tab-view.c
index fd781986..1ce92e9e 100644
--- a/src/adw-tab-view.c
+++ b/src/adw-tab-view.c
@@ -922,7 +922,7 @@ insert_page (AdwTabView *self,
              int         position,
              gboolean    pinned)
 {
-  g_autoptr (AdwTabPage) page =
+  AdwTabPage *page =
     g_object_new (ADW_TYPE_TAB_PAGE,
                   "child", child,
                   "parent", parent,
@@ -2654,7 +2654,7 @@ AdwTabPage *
 adw_tab_view_get_nth_page (AdwTabView *self,
                            int         position)
 {
-  g_autoptr (AdwTabPage) page = NULL;
+  AdwTabPage *page = NULL;
 
   g_return_val_if_fail (ADW_IS_TAB_VIEW (self), NULL);
   g_return_val_if_fail (position >= 0, NULL);
diff --git a/src/adw-tab.c b/src/adw-tab.c
index c295c3b5..cdf86c35 100644
--- a/src/adw-tab.c
+++ b/src/adw-tab.c
@@ -323,7 +323,7 @@ ensure_shader (AdwTab *self)
 {
   GtkNative *native;
   GskRenderer *renderer;
-  g_autoptr (GError) error = NULL;
+  GError *error = NULL;
 
   if (self->shader)
     return;
@@ -340,6 +340,7 @@ ensure_shader (AdwTab *self)
      * silently fall back */
     if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
       g_critical ("Couldn't compile shader: %s\n", error->message);
+    g_clear_error (&error);
   }
 }
 
diff --git a/src/adw-view-switcher.c b/src/adw-view-switcher.c
index 8170a328..a07b5ea2 100644
--- a/src/adw-view-switcher.c
+++ b/src/adw-view-switcher.c
@@ -94,8 +94,8 @@ update_button (AdwViewSwitcher  *self,
                AdwViewStackPage *page,
                GtkWidget        *button)
 {
-  g_autofree char *title = NULL;
-  g_autofree char *icon_name = NULL;
+  char *title = NULL;
+  char *icon_name = NULL;
   gboolean needs_attention;
   guint badge_number;
   gboolean visible;
@@ -119,6 +119,8 @@ update_button (AdwViewSwitcher  *self,
                 NULL);
 
   gtk_widget_set_visible (button, visible && (title != NULL || icon_name != NULL));
+  g_free (title);
+  g_free (icon_name);
 }
 
 static void


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