[libadwaita/msvc: 14/19] src: Remove g_auto* usage




commit be4ce40f4050e05a2472b3947a675c321e8a3f76
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                   | 34 ++++++++++++-----
 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                  |  6 ++-
 src/adw-tab-view.c                 |  5 ++-
 src/adw-tab.c                      |  3 +-
 src/adw-toast.c                    | 21 ++++++----
 src/adw-view-switcher.c            |  6 ++-
 16 files changed, 169 insertions(+), 93 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 9d329fee..701f888b 100644
--- a/src/adw-avatar.c
+++ b/src/adw-avatar.c
@@ -78,13 +78,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 ("");
 
@@ -99,6 +102,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);
 }
 
@@ -116,9 +121,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);
 
@@ -126,6 +131,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;
   }
@@ -133,12 +139,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 ||
@@ -149,6 +157,7 @@ update_initials (AdwAvatar *self)
   initials = extract_initials_from_text (self->text);
 
   gtk_label_set_label (self->label, initials);
+  g_free (initials);
 }
 
 static void
@@ -628,7 +637,7 @@ adw_avatar_set_custom_image (AdwAvatar    *self,
       gtk_image_set_from_paintable (self->custom_image, custom_image);
     } else {
       GtkSnapshot *snapshot = gtk_snapshot_new ();
-      g_autoptr (GdkPaintable) square_image = NULL;
+      GdkPaintable *square_image = NULL;
       int size = MIN (width, height);
 
       gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT ((size - width) / 2.f, (size - height) / 2.f));
@@ -636,6 +645,8 @@ adw_avatar_set_custom_image (AdwAvatar    *self,
 
       square_image = gtk_snapshot_free_to_paintable (snapshot, &GRAPHENE_SIZE_INIT (size, size));
       gtk_image_set_from_paintable (self->custom_image, square_image);
+
+      g_object_unref (square_image);
     }
 
     gtk_widget_add_css_class (self->gizmo, "image");
@@ -719,7 +730,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;
@@ -739,5 +751,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 5209124a..ff45471a 100644
--- a/src/adw-carousel-indicator-dots.c
+++ b/src/adw-carousel-indicator-dots.c
@@ -217,8 +217,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;
@@ -240,6 +240,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 72c97ded..d7a71a16 100644
--- a/src/adw-carousel-indicator-lines.c
+++ b/src/adw-carousel-indicator-lines.c
@@ -202,8 +202,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;
@@ -212,7 +212,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)
@@ -225,6 +228,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 0242b8e0..8ec9da27 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);
     }
@@ -221,7 +223,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);
@@ -233,6 +235,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");
   }
@@ -258,13 +261,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 08d0cf01..76edbda0 100644
--- a/src/adw-fading-label.c
+++ b/src/adw-fading-label.c
@@ -60,7 +60,7 @@ ensure_shader (AdwFadingLabel *self)
 {
   GtkNative *native;
   GskRenderer *renderer;
-  g_autoptr (GError) error = NULL;
+  GError *error = NULL;
 
   if (self->shader)
     return;
@@ -77,6 +77,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);
   }
 }
 
@@ -128,7 +130,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)
@@ -170,6 +172,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 01613a26..7078f13e 100644
--- a/src/adw-indicator-bin.c
+++ b/src/adw-indicator-bin.c
@@ -62,7 +62,7 @@ ensure_shader (AdwIndicatorBin *self)
 {
   GtkNative *native;
   GskRenderer *renderer;
-  g_autoptr (GError) error = NULL;
+  GError *error = NULL;
 
   if (self->shader)
     return;
@@ -79,6 +79,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);
   }
 }
 
@@ -167,7 +169,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);
@@ -193,6 +195,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 0d8af508..95224b98 100644
--- a/src/adw-preferences-window.c
+++ b/src/adw-preferences-window.c
@@ -84,7 +84,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;
 
@@ -96,6 +96,7 @@ strip_mnemonic (const char *src)
     if (c == (gunichar) -1) {
       g_warning ("Invalid input string");
 
+      g_free (new_str);
       return NULL;
     }
 
@@ -127,8 +128,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));
 
@@ -145,16 +147,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
@@ -182,7 +188,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);
 
@@ -204,14 +210,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)
@@ -226,7 +240,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));
 
@@ -238,6 +252,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 6c4420fd..72004e56 100644
--- a/src/adw-settings.c
+++ b/src/adw-settings.c
@@ -99,11 +99,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",
@@ -113,32 +114,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;
   }
 
@@ -149,13 +148,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
@@ -200,7 +204,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;
@@ -211,32 +215,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;
@@ -252,6 +252,7 @@ init_portal (AdwSettings *self)
   if (error) {
     g_debug ("Settings portal not found: %s", error->message);
 
+    g_error_free (error);
     return;
   }
 
@@ -260,6 +261,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 &&
@@ -267,12 +269,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)
@@ -306,8 +310,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. */
@@ -328,6 +332,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);
@@ -342,6 +347,7 @@ init_gsettings (AdwSettings *self)
                               "changed::high-contrast",
                               G_CALLBACK (gsettings_high_contrast_changed_cb),
                               self);
+    g_settings_schema_unref (a11y_schema);
   }
 }
 
@@ -350,14 +356,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 c642d3d4..65be0c8a 100644
--- a/src/adw-style-manager.c
+++ b/src/adw-style-manager.c
@@ -509,7 +509,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)
@@ -526,6 +526,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 a477e977..e76ddd14 100644
--- a/src/adw-swipe-tracker.c
+++ b/src/adw-swipe-tracker.c
@@ -169,13 +169,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
@@ -355,11 +356,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);
   }
@@ -378,7 +380,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;
 
@@ -388,7 +390,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;
@@ -416,6 +422,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 6b895a8a..a2e18504 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -1792,7 +1792,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;
 
@@ -1800,6 +1800,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
@@ -2303,7 +2304,7 @@ static void
 begin_drag (AdwTabBox *self,
             GdkDevice *device)
 {
-  g_autoptr (GdkContentProvider) content = NULL;
+  GdkContentProvider *content = NULL;
   GtkNative *native;
   GdkSurface *surface;
   GdkDrag *drag;
@@ -2358,6 +2359,7 @@ begin_drag (AdwTabBox *self,
 
   animate_scroll_relative (self, -self->placeholder_scroll_offset, CLOSE_ANIMATION_DURATION);
 
+  g_object_unref (content);
   g_object_unref (detached_tab);
 }
 
diff --git a/src/adw-tab-view.c b/src/adw-tab-view.c
index 18050baf..d23a8d33 100644
--- a/src/adw-tab-view.c
+++ b/src/adw-tab-view.c
@@ -934,7 +934,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,
@@ -954,6 +954,7 @@ insert_page (AdwTabView *self,
 
   g_object_thaw_notify (G_OBJECT (self));
 
+  g_object_unref (page);
   return page;
 }
 
@@ -2557,7 +2558,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 d135ce03..0a010608 100644
--- a/src/adw-tab.c
+++ b/src/adw-tab.c
@@ -309,7 +309,7 @@ ensure_shader (AdwTab *self)
 {
   GtkNative *native;
   GskRenderer *renderer;
-  g_autoptr (GError) error = NULL;
+  GError *error = NULL;
 
   if (self->shader)
     return;
@@ -326,6 +326,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-toast.c b/src/adw-toast.c
index 66914e65..09ea01be 100644
--- a/src/adw-toast.c
+++ b/src/adw-toast.c
@@ -644,9 +644,9 @@ void
 adw_toast_set_detailed_action_name (AdwToast   *self,
                                     const char *detailed_action_name)
 {
-  g_autofree char *name = NULL;
-  g_autoptr (GVariant) target = NULL;
-  g_autoptr (GError) error = NULL;
+  char *name = NULL;
+  GVariant *target = NULL;
+  GError *error = NULL;
 
   g_return_if_fail (ADW_IS_TOAST (self));
 
@@ -657,14 +657,19 @@ adw_toast_set_detailed_action_name (AdwToast   *self,
     return;
   }
 
-  if (!g_action_parse_detailed_name (detailed_action_name, &name, &target, &error)) {
+  if (g_action_parse_detailed_name (detailed_action_name, &name, &target, &error)) {
+    adw_toast_set_action_name (self, name);
+    adw_toast_set_action_target_value (self, target);
+  }
+  else
     g_critical ("Couldn't parse detailed action name: %s", error->message);
 
-    return;
-  }
+  g_clear_error (&error);
+
+  if (target != NULL)
+    g_variant_unref (target);
 
-  adw_toast_set_action_name (self, name);
-  adw_toast_set_action_target_value (self, target);
+  g_free (name);
 }
 
 /**
diff --git a/src/adw-view-switcher.c b/src/adw-view-switcher.c
index 747eb184..51de1c7e 100644
--- a/src/adw-view-switcher.c
+++ b/src/adw-view-switcher.c
@@ -96,8 +96,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;
@@ -121,6 +121,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]