[libhandy/msvc] src/: (WIP) Remove g_auto*()




commit 10ecbfcf6aa641f0885cdc2644eb08fd8584248f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jan 19 16:14:54 2022 +0800

    src/: (WIP) Remove g_auto*()
    
    g_auto*() macros are unfortunately GCCism's that don't work on Visual Studio,
    so drop them.

 src/gtk-window.c                   |  11 ++-
 src/hdy-avatar-icon.c              |  31 +++----
 src/hdy-avatar.c                   | 170 +++++++++++++++++++++++++++----------
 src/hdy-carousel-box.c             |  12 ++-
 src/hdy-carousel-indicator-dots.c  |  12 ++-
 src/hdy-carousel-indicator-lines.c |   7 +-
 src/hdy-expander-row.c             |   4 +-
 src/hdy-header-bar.c               |   4 +-
 src/hdy-header-group.c             |  22 +++--
 src/hdy-keypad-button.c            |   4 +-
 src/hdy-keypad.c                   |   9 +-
 src/hdy-main.c                     |  15 +++-
 src/hdy-preferences-group.c        |   4 +-
 src/hdy-preferences-window.c       |  29 +++++--
 src/hdy-settings.c                 |  18 ++--
 src/hdy-shadow-helper.c            |  23 +++--
 src/hdy-stackable-box.c            |   8 +-
 src/hdy-style-manager.c            |  53 +++++++++---
 src/hdy-swipe-tracker.c            |  29 +++++--
 src/hdy-tab-view.c                 |   8 +-
 src/hdy-window-handle-controller.c |  18 +++-
 src/hdy-window-mixin.c             |  15 +++-
 22 files changed, 366 insertions(+), 140 deletions(-)
---
diff --git a/src/gtk-window.c b/src/gtk-window.c
index 154acdbe..76f5241b 100644
--- a/src/gtk-window.c
+++ b/src/gtk-window.c
@@ -133,7 +133,7 @@ hdy_gtk_window_get_icon_for_size (GtkWindow *window,
 {
   GtkWindowIconInfo *info;
   const gchar *name;
-  g_autoptr (GList) default_icon_list = gtk_window_get_default_icon_list ();
+  GList *default_icon_list = gtk_window_get_default_icon_list ();
 
   info = ensure_icon_info (window);
 
@@ -151,8 +151,13 @@ hdy_gtk_window_get_icon_for_size (GtkWindow *window,
         return icon_from_list (info->icon_list, size);
     }
 
-  if (default_icon_list != NULL)
-    return icon_from_list (default_icon_list, size);
+  if (default_icon_list != NULL) {
+    GdkPixbuf *icon_pixbuf = icon_from_list (default_icon_list, size);
+
+    g_list_free (default_icon_list);
+
+    return icon_pixbuf;
+  }
 
   if (gtk_window_get_default_icon_name () != NULL)
     return icon_from_name (gtk_window_get_default_icon_name (), size);
diff --git a/src/hdy-avatar-icon.c b/src/hdy-avatar-icon.c
index 8d8c883d..bf04da49 100644
--- a/src/hdy-avatar-icon.c
+++ b/src/hdy-avatar-icon.c
@@ -78,22 +78,19 @@ load_pixbuf_cb (GObject      *source_object,
                 GAsyncResult *res,
                 gpointer      data)
 {
-  g_autoptr (GTask) task = G_TASK (data);
-  g_autoptr (GError) error = NULL;
-  g_autoptr (GInputStream) stream = NULL;
+  GTask *task = G_TASK (data);
+  GError *error = NULL;
 
-  if (g_task_return_error_if_cancelled (task))
-    return;
+  if (!g_task_return_error_if_cancelled (task)) {
+    GInputStream *stream = g_loadable_icon_load_finish (G_LOADABLE_ICON (source_object), res, NULL, &error);
 
-  stream = g_loadable_icon_load_finish (G_LOADABLE_ICON (source_object), res, NULL, &error);
-
-  if (stream == NULL) {
-    g_task_return_error (task, g_steal_pointer (&error));
-
-    return;
+    if (stream == NULL)
+      g_task_return_error (task, error);
+    else
+      g_task_return_pointer (task, stream, g_object_unref);
   }
 
-  g_task_return_pointer (task, g_steal_pointer (&stream), g_object_unref);
+  g_object_unref (task);
 }
 
 static void
@@ -104,8 +101,8 @@ hdy_avatar_icon_load_async (GLoadableIcon       *icon,
                             gpointer             user_data)
 {
   HdyAvatarIcon *self;
-  g_autoptr (GTask) task = NULL;
-  g_autoptr (GdkPixbuf) pixbuf = NULL;
+  GTask *task = NULL;
+  GdkPixbuf *pixbuf = NULL;
   g_return_if_fail (HDY_IS_AVATAR_ICON (icon));
 
   self = HDY_AVATAR_ICON (icon);
@@ -123,13 +120,17 @@ hdy_avatar_icon_load_async (GLoadableIcon       *icon,
                                 size,
                                 cancellable,
                                 load_pixbuf_cb,
-                                g_steal_pointer (&task));
+                                task);
+
+    g_object_unref (pixbuf);
   } else {
     g_task_return_new_error (task,
                              HDY_AVATAR_ICON_ERROR,
                              HDY_AVATAR_ICON_ERROR_EMPTY,
                              "No pixbuf set");
   }
+
+  g_object_unref (task);
 }
 
 static GInputStream *
diff --git a/src/hdy-avatar.c b/src/hdy-avatar.c
index 3a022733..f4ff4a00 100644
--- a/src/hdy-avatar.c
+++ b/src/hdy-avatar.c
@@ -110,10 +110,11 @@ static GdkPixbuf *
 make_round_image (GdkPixbuf *pixbuf,
                   gdouble    size)
 {
-  g_autoptr (cairo_surface_t) surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
-  g_autoptr (cairo_t) cr = cairo_create (surface);
+  cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
+  cairo_t *cr = cairo_create (surface);
   gint width = gdk_pixbuf_get_width (pixbuf);
   gint height = gdk_pixbuf_get_height (pixbuf);
+  GdkPixbuf *resulting_pixbuf;
 
   /* Clip a circle */
   cairo_arc (cr, size / 2.0, size / 2.0, size / 2.0, 0, 2 * G_PI);
@@ -123,20 +124,28 @@ make_round_image (GdkPixbuf *pixbuf,
   gdk_cairo_set_source_pixbuf (cr, pixbuf, (size - width) / 2, (size - height) / 2);
   cairo_paint (cr);
 
-  return gdk_pixbuf_get_from_surface (surface, 0, 0, size, size);
+  resulting_pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, size, size);
+
+  cairo_surface_destroy (surface);
+  cairo_destroy (cr);
+
+  return resulting_pixbuf;
 }
 
 static gchar *
 extract_initials_from_text (const gchar *text)
 {
   GString *initials;
-  g_autofree gchar *p = g_utf8_strup (text, -1);
-  g_autofree gchar *normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
+  gchar *p = g_utf8_strup (text, -1);
+  gchar *normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
   gunichar unichar;
   gchar *q = NULL;
 
-  if (normalized == NULL)
+  if (normalized == NULL) {
+    g_free (p);
+
     return NULL;
+  }
 
   initials = g_string_new ("");
 
@@ -151,6 +160,9 @@ extract_initials_from_text (const gchar *text)
     g_string_append_unichar (initials, unichar);
   }
 
+  g_free (normalized);
+  g_free (p);
+
   return g_string_free (initials, FALSE);
 }
 
@@ -214,9 +226,9 @@ load_from_stream_async_cb (GObject      *stream,
                            GAsyncResult *res,
                            gpointer      data)
 {
-  g_autoptr (GTask) task = data;
+  GTask *task = data;
   GdkPixbufLoader *loader = g_task_get_task_data (task);
-  g_autoptr (GBytes) bytes = NULL;
+  GBytes *bytes = NULL;
   GError *error = NULL;
 
   bytes = g_input_stream_read_bytes_finish (G_INPUT_STREAM (stream), res, &error);
@@ -224,6 +236,8 @@ load_from_stream_async_cb (GObject      *stream,
     gdk_pixbuf_loader_close (loader, NULL);
     g_task_return_error (task, error);
 
+    g_object_unref (task);
+
     return;
   }
 
@@ -231,6 +245,9 @@ load_from_stream_async_cb (GObject      *stream,
     if (!gdk_pixbuf_loader_close (loader, &error)) {
       g_task_return_error (task, error);
 
+      g_bytes_unref (bytes);
+      g_object_unref (task);
+
       return;
     }
 
@@ -238,6 +255,9 @@ load_from_stream_async_cb (GObject      *stream,
                            g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader)),
                            g_object_unref);
 
+    g_bytes_unref (bytes);
+    g_object_unref (task);
+
     return;
   }
 
@@ -248,6 +268,9 @@ load_from_stream_async_cb (GObject      *stream,
     gdk_pixbuf_loader_close (loader, NULL);
     g_task_return_error (task, error);
 
+    g_bytes_unref (bytes);
+    g_object_unref (task);
+
     return;
   }
 
@@ -257,6 +280,9 @@ load_from_stream_async_cb (GObject      *stream,
                                    g_task_get_cancellable (task),
                                    load_from_stream_async_cb,
                                    g_object_ref (task));
+
+  g_bytes_unref (bytes);
+  g_object_unref (task);
 }
 
 static void
@@ -265,13 +291,14 @@ icon_load_async_cb (GLoadableIcon *icon,
                     GTask         *task)
 {
   GdkPixbufLoader *loader = g_task_get_task_data (task);
-  g_autoptr (GInputStream) stream = NULL;
-  g_autoptr (GError) error = NULL;
+  GInputStream *stream = NULL;
+  GError *error = NULL;
 
   stream = g_loadable_icon_load_finish (icon, res, NULL, &error);
   if (stream == NULL) {
     gdk_pixbuf_loader_close (loader, NULL);
-    g_task_return_error (task, g_steal_pointer (&error));
+    g_task_return_error (task, error);
+
     g_object_unref (task);
 
     return;
@@ -283,6 +310,8 @@ icon_load_async_cb (GLoadableIcon *icon,
                                    g_task_get_cancellable (task),
                                    load_from_stream_async_cb,
                                    task);
+
+  g_object_unref (stream);
 }
 
 static GdkPixbuf *
@@ -299,8 +328,8 @@ load_from_gicon_async_for_display_cb (HdyAvatar    *self,
                                       GAsyncResult *res,
                                       gpointer     *user_data)
 {
-  g_autoptr (GError) error = NULL;
-  g_autoptr (GdkPixbuf) pixbuf = NULL;
+  GError *error = NULL;
+  GdkPixbuf *pixbuf = NULL;
 
   pixbuf = load_from_gicon_async_finish (res, &error);
 
@@ -311,12 +340,14 @@ load_from_gicon_async_for_display_cb (HdyAvatar    *self,
       g_warning ("Failed to load icon: %s", error->message);
       self->loading_error = TRUE;
     }
+
+    g_clear_error (&error);
   }
 
   self->currently_loading_size = -1;
 
   if (pixbuf) {
-    g_autoptr (GdkPixbuf) custom_image = NULL;
+    GdkPixbuf *custom_image = NULL;
     GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self));
     gint width = gtk_widget_get_allocated_width (GTK_WIDGET (self));
     gint height = gtk_widget_get_allocated_height (GTK_WIDGET (self));
@@ -334,6 +365,9 @@ load_from_gicon_async_for_display_cb (HdyAvatar    *self,
 
     g_set_object (&self->round_image, custom_image);
     gtk_widget_queue_draw (GTK_WIDGET (self));
+
+    g_object_unref (custom_image);
+    g_object_unref (pixbuf);
   }
 }
 
@@ -343,8 +377,8 @@ load_from_gicon_async_for_export_cb (HdyAvatar    *self,
                                      gpointer     *user_data)
 {
   GTask *task = G_TASK (user_data);
-  g_autoptr (GError) error = NULL;
-  g_autoptr (GdkPixbuf) pixbuf = NULL;
+  GError *error = NULL;
+  GdkPixbuf *pixbuf = NULL;
 
   pixbuf = load_from_gicon_async_finish (res, &error);
 
@@ -352,10 +386,12 @@ load_from_gicon_async_for_export_cb (HdyAvatar    *self,
       !g_error_matches (error, HDY_AVATAR_ICON_ERROR, HDY_AVATAR_ICON_ERROR_EMPTY) &&
       !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
     g_warning ("Failed to load icon: %s", error->message);
+
+    g_clear_error (&error);
   }
 
   g_task_return_pointer (task,
-                         g_steal_pointer (&pixbuf),
+                         pixbuf,
                          g_object_unref);
   g_object_unref (task);
 }
@@ -430,10 +466,10 @@ static GdkPixbuf *
 load_icon_sync (GLoadableIcon *icon,
                 gint           size)
 {
-  g_autoptr (GError) error = NULL;
-  g_autoptr (GInputStream) stream = g_loadable_icon_load (icon, size, NULL, NULL, &error);
-  g_autoptr (GdkPixbufLoader) loader = gdk_pixbuf_loader_new ();
-  g_autoptr (GdkPixbuf) pixbuf = NULL;
+  GError *error = NULL;
+  GInputStream *stream = g_loadable_icon_load (icon, size, NULL, NULL, &error);
+  GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+  GdkPixbuf *pixbuf = NULL;
 
   if (error) {
     g_warning ("Failed to load icon: %s", error->message);
@@ -446,34 +482,44 @@ load_icon_sync (GLoadableIcon *icon,
 
   pixbuf = load_from_stream (loader, stream, NULL, &error);
 
+  g_object_unref (loader);
+  g_object_unref (stream);
+
   if (error) {
     g_warning ("Failed to load pixbuf from GLoadableIcon: %s", error->message);
+
+    g_clear_error (&error);
+
     return NULL;
   }
 
-  return g_steal_pointer (&pixbuf);
+  return pixbuf;
 }
 
 static void
 set_class_color (HdyAvatar *self)
 {
   GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self));
-  g_autofree GRand *rand = NULL;
-  g_autofree gchar *new_class = NULL;
-  g_autofree gchar *old_class = g_strdup_printf ("color%d", self->color_class);
+  gchar *new_class = NULL;
+  gchar *old_class = g_strdup_printf ("color%d", self->color_class);
 
   gtk_style_context_remove_class (context, old_class);
 
   if (self->text == NULL || strlen (self->text) == 0) {
     /* Use a random color if we don't have a text */
-    rand = g_rand_new ();
+    GRand *rand = g_rand_new ();
     self->color_class = g_rand_int_range (rand, 1, NUMBER_OF_COLORS);
+
+    g_free (rand);
   } else {
     self->color_class = (g_str_hash (self->text) % NUMBER_OF_COLORS) + 1;
   }
 
   new_class = g_strdup_printf ("color%d", self->color_class);
   gtk_style_context_add_class (context, new_class);
+
+  g_free (new_class);
+  g_free (old_class);
 }
 
 static void
@@ -497,13 +543,15 @@ clear_pango_layout (HdyAvatar *self)
 static void
 ensure_pango_layout (HdyAvatar *self)
 {
-  g_autofree gchar *initials = NULL;
+  gchar *initials = NULL;
 
   if (self->layout != NULL || self->text == NULL || strlen (self->text) == 0)
     return;
 
   initials = extract_initials_from_text (self->text);
   self->layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), initials);
+
+  g_free (initials);
 }
 
 static void
@@ -655,10 +703,10 @@ draw_for_size (HdyAvatar *self,
   gdouble y = (gdouble)(height - size) / 2.0;
   const gchar *icon_name;
   GdkRGBA color;
-  g_autoptr (GtkIconInfo) icon = NULL;
-  g_autoptr (GdkPixbuf) pixbuf = NULL;
-  g_autoptr (GError) error = NULL;
-  g_autoptr (cairo_surface_t) surface = NULL;
+  GtkIconInfo *icon = NULL;
+  GdkPixbuf *pixbuf = NULL;
+  GError *error = NULL;
+  cairo_surface_t *surface = NULL;
 
   set_class_contrasted (self, size);
 
@@ -668,6 +716,9 @@ draw_for_size (HdyAvatar *self,
     gtk_render_icon_surface (context, cr, surface, x, y);
     gtk_render_background (context, cr, x, y, size, size);
     gtk_render_frame (context, cr, x, y, size, size);
+
+    cairo_surface_destroy (surface);
+
     return;
   }
 
@@ -702,6 +753,10 @@ draw_for_size (HdyAvatar *self,
   pixbuf = gtk_icon_info_load_symbolic (icon, &color, NULL, NULL, NULL, NULL, &error);
   if (error != NULL) {
     g_critical ("Failed to load icon `%s': %s", icon_name, error->message);
+
+    g_object_unref (icon);
+    g_clear_error (&error);
+
     return;
   }
 
@@ -713,6 +768,10 @@ draw_for_size (HdyAvatar *self,
   gtk_render_icon_surface (context, cr, surface,
                            (((gdouble) size - ((gdouble) width / (gdouble) scale_factor)) / 2.0) + x,
                            (((gdouble) size - ((gdouble) height / (gdouble) scale_factor)) / 2.0) + y);
+
+  g_object_unref (icon);
+  g_object_unref (pixbuf);
+  cairo_surface_destroy (surface);
 }
 
 static gboolean
@@ -1119,7 +1178,7 @@ hdy_avatar_set_image_load_func (HdyAvatar              *self,
                                 gpointer                user_data,
                                 GDestroyNotify          destroy)
 {
-  g_autoptr (HdyAvatarIcon) icon = NULL;
+  HdyAvatarIcon *icon = NULL;
 
   g_return_if_fail (HDY_IS_AVATAR (self));
   g_return_if_fail (user_data != NULL || (user_data == NULL && destroy == NULL));
@@ -1136,6 +1195,8 @@ hdy_avatar_set_image_load_func (HdyAvatar              *self,
 
   g_set_object (&self->load_func_icon, icon);
 
+  g_object_unref (icon);
+
   /* Don't update the custom avatar when we have a user set GLoadableIcon */
   if (self->icon)
     return;
@@ -1211,10 +1272,10 @@ hdy_avatar_draw_to_pixbuf (HdyAvatar *self,
                            gint       size,
                            gint       scale_factor)
 {
-  g_autoptr (cairo_surface_t) surface = NULL;
-  g_autoptr (cairo_t) cr = NULL;
-  g_autoptr (GdkPixbuf) custom_image = NULL;
-  g_autoptr (GdkPixbuf) pixbuf_from_icon = NULL;
+  cairo_surface_t *surface = NULL;
+  cairo_t *cr = NULL;
+  GdkPixbuf *custom_image = NULL;
+  GdkPixbuf *pixbuf_from_icon = NULL;
   gint scaled_size = size * scale_factor;
   GtkStyleContext *context;
   GtkAllocation bounds;
@@ -1242,6 +1303,8 @@ hdy_avatar_draw_to_pixbuf (HdyAvatar *self,
       pixbuf_from_icon = load_icon_sync (get_icon (self), scaled_size);
       custom_image = update_custom_image (pixbuf_from_icon, NULL, scaled_size);
       gtk_style_context_add_class (context, "image");
+
+      g_object_unref (custom_image);
     } else {
       custom_image = update_custom_image (NULL, self->round_image, scaled_size);
     }
@@ -1249,6 +1312,9 @@ hdy_avatar_draw_to_pixbuf (HdyAvatar *self,
 
   draw_for_size (self, cr, custom_image, size, size, scale_factor);
 
+  g_object_unref (custom_image);
+  cairo_destroy (cr);
+
   return gdk_pixbuf_get_from_surface (surface, 0, 0,
                                       bounds.width * scale_factor,
                                       bounds.height * scale_factor);
@@ -1276,7 +1342,7 @@ hdy_avatar_draw_to_pixbuf_async (HdyAvatar           *self,
                                  GAsyncReadyCallback  callback,
                                  gpointer             user_data)
 {
-  g_autoptr (GTask) task = NULL;
+  GTask *task = NULL;
   gint scaled_size = size * scale_factor;
   SizeData *data;
 
@@ -1295,14 +1361,17 @@ hdy_avatar_draw_to_pixbuf_async (HdyAvatar           *self,
   if (get_icon (self) &&
       (!self->round_image ||
        gdk_pixbuf_get_width (self->round_image) != scaled_size ||
-       is_scaled (self->round_image)))
+       is_scaled (self->round_image))) {
     load_icon_async (self,
                      scaled_size,
                      cancellable,
                      (GAsyncReadyCallback) load_from_gicon_async_for_export_cb,
-                     g_steal_pointer (&task));
-  else
+                     task);
+  } else {
     g_task_return_pointer (task, NULL, NULL);
+
+    g_object_unref (task);
+  }
 }
 
 /**
@@ -1321,13 +1390,14 @@ hdy_avatar_draw_to_pixbuf_finish (HdyAvatar    *self,
                                   GAsyncResult *async_result)
 {
   GTask *task;
-  g_autoptr (GdkPixbuf) pixbuf_from_icon = NULL;
-  g_autoptr (GdkPixbuf) custom_image = NULL;
-  g_autoptr (cairo_surface_t) surface = NULL;
-  g_autoptr (cairo_t) cr = NULL;
+  GdkPixbuf *pixbuf_from_icon = NULL;
+  GdkPixbuf *custom_image = NULL;
+  cairo_surface_t *surface = NULL;
+  cairo_t *cr = NULL;
   SizeData *data;
   GtkStyleContext *context;
   GtkAllocation bounds;
+  GdkPixbuf *result_pixbuf;
 
   g_return_val_if_fail (G_IS_TASK (async_result), NULL);
 
@@ -1354,9 +1424,15 @@ hdy_avatar_draw_to_pixbuf_finish (HdyAvatar    *self,
                                       data->size * data->scale_factor);
   draw_for_size (self, cr, custom_image, data->size, data->size, data->scale_factor);
 
-  return gdk_pixbuf_get_from_surface (surface, 0, 0,
-                                      bounds.width * data->scale_factor,
-                                      bounds.height * data->scale_factor);
+
+  result_pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
+                                               bounds.width * data->scale_factor,
+                                               bounds.height * data->scale_factor);
+
+  cairo_destroy (cr);
+  cairo_surface_destroy (surface);
+
+  return result_pixbuf;
 }
 
 /**
diff --git a/src/hdy-carousel-box.c b/src/hdy-carousel-box.c
index d3aab027..8b81891f 100644
--- a/src/hdy-carousel-box.c
+++ b/src/hdy-carousel-box.c
@@ -435,7 +435,7 @@ animation_cb (GtkWidget     *widget,
               gpointer       user_data)
 {
   HdyCarouselBox *self = HDY_CAROUSEL_BOX (widget);
-  g_autoptr (GList) children = NULL;
+  GList *children = NULL;
   GList *l;
   gboolean should_continue;
   gdouble position_shift;
@@ -473,6 +473,8 @@ animation_cb (GtkWidget     *widget,
   if (!should_continue)
     self->tick_cb_id = 0;
 
+  g_list_free (children);
+
   return should_continue;
 }
 
@@ -571,7 +573,7 @@ hdy_carousel_box_draw (GtkWidget *widget,
       continue;
 
     if (info->dirty_region && !info->removing) {
-      g_autoptr (cairo_t) surface_cr = NULL;
+      cairo_t *surface_cr = NULL;
       GtkAllocation child_alloc;
 
       if (!info->surface) {
@@ -607,6 +609,8 @@ hdy_carousel_box_draw (GtkWidget *widget,
 
       cairo_region_destroy (info->dirty_region);
       info->dirty_region = NULL;
+
+      cairo_destroy (surface_cr);
     }
 
     if (!info->surface)
@@ -962,7 +966,7 @@ hdy_carousel_box_forall (GtkContainer *container,
                          gpointer      callback_data)
 {
   HdyCarouselBox *self = HDY_CAROUSEL_BOX (container);
-  g_autoptr (GList) children = NULL;
+  GList *children = NULL;
   GList *l;
 
   children = g_list_copy (self->children);
@@ -972,6 +976,8 @@ hdy_carousel_box_forall (GtkContainer *container,
     if (!child->removing)
        (* callback) (child->widget, callback_data);
   }
+
+  g_list_free (children);
 }
 
 static void
diff --git a/src/hdy-carousel-indicator-dots.c b/src/hdy-carousel-indicator-dots.c
index 5bbc5417..f0816d1d 100644
--- a/src/hdy-carousel-indicator-dots.c
+++ b/src/hdy-carousel-indicator-dots.c
@@ -278,8 +278,8 @@ hdy_carousel_indicator_dots_draw (GtkWidget *widget,
   HdyCarouselIndicatorDots *self = HDY_CAROUSEL_INDICATOR_DOTS (widget);
   gint i, n_points;
   gdouble position;
-  g_autofree gdouble *points = NULL;
-  g_autofree gdouble *sizes = NULL;
+  gdouble *points = NULL;
+  gdouble *sizes = NULL;
 
   if (!self->carousel)
     return GDK_EVENT_PROPAGATE;
@@ -287,8 +287,11 @@ hdy_carousel_indicator_dots_draw (GtkWidget *widget,
   points = hdy_swipeable_get_snap_points (HDY_SWIPEABLE (self->carousel), &n_points);
   position = hdy_carousel_get_position (self->carousel);
 
-  if (n_points < 2)
+  if (n_points < 2) {
+    g_free (points);
+
     return GDK_EVENT_PROPAGATE;
+  }
 
   if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
       gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
@@ -302,6 +305,9 @@ hdy_carousel_indicator_dots_draw (GtkWidget *widget,
 
   draw_dots (widget, cr, self->orientation, position, sizes, n_points);
 
+  g_free (sizes);
+  g_free (points);
+
   return GDK_EVENT_PROPAGATE;
 }
 
diff --git a/src/hdy-carousel-indicator-lines.c b/src/hdy-carousel-indicator-lines.c
index fba9b380..9d50fce6 100644
--- a/src/hdy-carousel-indicator-lines.c
+++ b/src/hdy-carousel-indicator-lines.c
@@ -277,8 +277,8 @@ hdy_carousel_indicator_lines_draw (GtkWidget *widget,
   HdyCarouselIndicatorLines *self = HDY_CAROUSEL_INDICATOR_LINES (widget);
   gint i, n_points;
   gdouble position;
-  g_autofree gdouble *points = NULL;
-  g_autofree gdouble *sizes = NULL;
+  gdouble *points = NULL;
+  gdouble *sizes = NULL;
 
   if (!self->carousel)
     return GDK_EVENT_PROPAGATE;
@@ -301,6 +301,9 @@ hdy_carousel_indicator_lines_draw (GtkWidget *widget,
 
   draw_lines (widget, cr, self->orientation, position, sizes, n_points);
 
+  g_free (sizes);
+  g_free (points);
+  
   return GDK_EVENT_PROPAGATE;
 }
 
diff --git a/src/hdy-expander-row.c b/src/hdy-expander-row.c
index 55bf6952..d254112c 100644
--- a/src/hdy-expander-row.c
+++ b/src/hdy-expander-row.c
@@ -84,13 +84,15 @@ update_arrow (HdyExpanderRow *self)
   GtkWidget *previous_sibling = NULL;
 
   if (parent) {
-    g_autoptr (GList) siblings = gtk_container_get_children (GTK_CONTAINER (parent));
+    GList *siblings = gtk_container_get_children (GTK_CONTAINER (parent));
     GList *l;
 
     for (l = siblings; l != NULL && l->next != NULL && l->next->data != self; l = l->next);
 
     if (l && l->next && l->next->data == self)
       previous_sibling = l->data;
+
+    g_list_free (siblings);
   }
 
   if (priv->expanded)
diff --git a/src/hdy-header-bar.c b/src/hdy-header-bar.c
index e07f31a8..619b7ade 100644
--- a/src/hdy-header-bar.c
+++ b/src/hdy-header-bar.c
@@ -328,13 +328,15 @@ hdy_header_bar_update_window_icon (HdyHeaderBar *self,
     pixbuf = hdy_gtk_window_get_icon_for_size (window, scale * 20);
 
   if (pixbuf) {
-    g_autoptr (cairo_surface_t) surface =
+    cairo_surface_t *surface =
       gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, gtk_widget_get_window (priv->titlebar_icon));
 
     gtk_image_set_from_surface (GTK_IMAGE (priv->titlebar_icon), surface);
     g_object_unref (pixbuf);
     gtk_widget_show (priv->titlebar_icon);
 
+    cairo_surface_destroy (surface);
+
     return TRUE;
   }
 
diff --git a/src/hdy-header-group.c b/src/hdy-header-group.c
index cb99c7ae..698ba661 100644
--- a/src/hdy-header-group.c
+++ b/src/hdy-header-group.c
@@ -324,10 +324,10 @@ update_decoration_layouts (HdyHeaderGroup *self)
   GSList *children;
   GtkSettings *settings;
   HdyHeaderGroupChild *start_child = NULL, *end_child = NULL;
-  g_autofree gchar *layout = NULL;
-  g_autofree gchar *start_layout = NULL;
-  g_autofree gchar *end_layout = NULL;
-  g_auto(GStrv) ends = NULL;
+  gchar *layout = NULL;
+  gchar *start_layout = NULL;
+  gchar *end_layout = NULL;
+  GStrv ends = NULL;
 
   g_return_if_fail (HDY_IS_HEADER_GROUP (self));
 
@@ -348,6 +348,8 @@ update_decoration_layouts (HdyHeaderGroup *self)
     for (; children != NULL; children = children->next)
       hdy_header_group_child_set_decoration_layout (HDY_HEADER_GROUP_CHILD (children->data), layout);
 
+    g_free (layout);
+
     return;
   }
 
@@ -365,12 +367,17 @@ update_decoration_layouts (HdyHeaderGroup *self)
       end_child = child;
   }
 
-  if (start_child == NULL || end_child == NULL)
+  if (start_child == NULL || end_child == NULL) {
+    g_free (layout);
+
     return;
+  }
 
   if (start_child == end_child) {
     hdy_header_group_child_set_decoration_layout (start_child, layout);
 
+    g_free (layout);
+
     return;
   }
 
@@ -384,6 +391,11 @@ update_decoration_layouts (HdyHeaderGroup *self)
   }
   hdy_header_group_child_set_decoration_layout (start_child, start_layout);
   hdy_header_group_child_set_decoration_layout (end_child, end_layout);
+
+  g_free (start_layout);
+  g_free (end_layout);
+  g_strfreev (ends);
+  g_free (layout);
 }
 
 static void
diff --git a/src/hdy-keypad-button.c b/src/hdy-keypad-button.c
index 436555d8..2b543d91 100644
--- a/src/hdy-keypad-button.c
+++ b/src/hdy-keypad-button.c
@@ -41,7 +41,7 @@ G_DEFINE_TYPE (HdyKeypadButton, hdy_keypad_button, GTK_TYPE_BUTTON)
 static void
 format_label(HdyKeypadButton *self)
 {
-  g_autofree gchar *text = NULL;
+  gchar *text = NULL;
   gchar *secondary_text = NULL;
 
   if (self->symbols != NULL && *(self->symbols) != '\0') {
@@ -51,6 +51,8 @@ format_label(HdyKeypadButton *self)
 
   gtk_label_set_label (self->label, text);
   gtk_label_set_label (self->secondary_label, secondary_text);
+
+  g_free (text);
 }
 
 static void
diff --git a/src/hdy-keypad.c b/src/hdy-keypad.c
index 1d947ab1..0c2f2094 100644
--- a/src/hdy-keypad.c
+++ b/src/hdy-keypad.c
@@ -58,10 +58,13 @@ symbol_clicked (HdyKeypad *self,
                 gchar      symbol)
 {
   HdyKeypadPrivate *priv = hdy_keypad_get_instance_private (self);
-  g_autofree gchar *string = g_strdup_printf ("%c", symbol);
+  gchar *string = g_strdup_printf ("%c", symbol);
+
+  if (!priv->entry) {
+    g_free (string);
 
-  if (!priv->entry)
     return;
+  }
 
   g_signal_emit_by_name (priv->entry, "insert-at-cursor", string, NULL);
   /* Set focus to the entry only when it can get focus
@@ -69,6 +72,8 @@ symbol_clicked (HdyKeypad *self,
    */
   if (gtk_widget_get_can_focus (GTK_WIDGET (priv->entry)))
     gtk_entry_grab_focus_without_selecting (priv->entry);
+
+  g_string (string);
 }
 
 
diff --git a/src/hdy-main.c b/src/hdy-main.c
index 008cdb2c..3c6d86d7 100644
--- a/src/hdy-main.c
+++ b/src/hdy-main.c
@@ -69,8 +69,8 @@ hdy_themes_get_theme_name (gboolean *prefer_dark_theme)
 static void
 hdy_themes_update (GtkCssProvider *css_provider)
 {
-  g_autofree gchar *theme_name = NULL;
-  g_autofree gchar *resource_path = NULL;
+  gchar *theme_name = NULL;
+  gchar *resource_path = NULL;
   gboolean prefer_dark_theme = FALSE;
 
   g_assert (GTK_IS_CSS_PROVIDER (css_provider));
@@ -96,12 +96,15 @@ hdy_themes_update (GtkCssProvider *css_provider)
   }
 
   gtk_css_provider_load_from_resource (css_provider, resource_path);
+
+  g_free (resource_path);
+  g_free (theme_name);
 }
 
 static void
 load_fallback_style (void)
 {
-  g_autoptr (GtkCssProvider) css_provider = NULL;
+  GtkCssProvider *css_provider = NULL;
 
   css_provider = gtk_css_provider_new ();
   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
@@ -109,6 +112,8 @@ load_fallback_style (void)
                                              GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
 
   gtk_css_provider_load_from_resource (css_provider, HDY_THEMES_PATH"fallback.css");
+
+  g_object_unref (css_provider);
 }
 
 /**
@@ -123,7 +128,7 @@ static void
 hdy_style_init (void)
 {
   static gsize guard = 0;
-  g_autoptr (GtkCssProvider) css_provider = NULL;
+  GtkCssProvider *css_provider = NULL;
   GtkSettings *settings;
 
   if (!g_once_init_enter (&guard))
@@ -148,6 +153,8 @@ hdy_style_init (void)
 
   load_fallback_style ();
 
+  g_object_unref (css_provider);
+
   g_once_init_leave (&guard, 1);
 }
 
diff --git a/src/hdy-preferences-group.c b/src/hdy-preferences-group.c
index b4a96285..a54c21c8 100644
--- a/src/hdy-preferences-group.c
+++ b/src/hdy-preferences-group.c
@@ -76,7 +76,7 @@ static void
 update_listbox_visibility (HdyPreferencesGroup *self)
 {
   HdyPreferencesGroupPrivate *priv = hdy_preferences_group_get_instance_private (self);
-  g_autoptr(GList) children = NULL;
+  GList *children = NULL;
 
   /* We must wait until the listbox has been built and added. */
   if (priv->listbox == NULL)
@@ -85,6 +85,8 @@ update_listbox_visibility (HdyPreferencesGroup *self)
   children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
 
   gtk_widget_set_visible (GTK_WIDGET (priv->listbox), children != NULL);
+
+  g_list_free (children);
 }
 
 static gboolean
diff --git a/src/hdy-preferences-window.c b/src/hdy-preferences-window.c
index 84180140..b83d51de 100644
--- a/src/hdy-preferences-window.c
+++ b/src/hdy-preferences-window.c
@@ -69,7 +69,7 @@ static GParamSpec *props[LAST_PROP];
 static gchar *
 strip_mnemonic (const gchar *src)
 {
-  g_autofree gchar *new_str = g_new (gchar, strlen (src) + 1);
+  gchar *new_str = g_new (gchar, strlen (src) + 1);
   gchar *dest = new_str;
   gboolean underscore = FALSE;
 
@@ -104,7 +104,7 @@ strip_mnemonic (const gchar *src)
 
   *dest = 0;
 
-  return g_steal_pointer (&new_str);
+  return new_str;
 }
 
 static gboolean
@@ -112,9 +112,9 @@ filter_search_results (HdyActionRow         *row,
                        HdyPreferencesWindow *self)
 {
   HdyPreferencesWindowPrivate *priv = hdy_preferences_window_get_instance_private (self);
-  g_autofree gchar *text = g_utf8_casefold (gtk_entry_get_text (GTK_ENTRY (priv->search_entry)), -1);
-  g_autofree gchar *title = g_utf8_casefold (hdy_preferences_row_get_title (HDY_PREFERENCES_ROW (row)), -1);
-  g_autofree gchar *subtitle = NULL;
+  gchar *text = g_utf8_casefold (gtk_entry_get_text (GTK_ENTRY (priv->search_entry)), -1);
+  gchar *title = g_utf8_casefold (hdy_preferences_row_get_title (HDY_PREFERENCES_ROW (row)), -1);
+  gchar *subtitle = NULL;
 
   /* The CSS engine works in such a way that invisible children are treated as
    * visible widgets, which breaks the expectations of the .preferences  style
@@ -140,6 +140,9 @@ filter_search_results (HdyActionRow         *row,
     priv->n_last_search_results++;
     gtk_widget_show (GTK_WIDGET (row));
 
+    g_free (title);
+    g_free (text);
+
     return TRUE;
   }
 
@@ -149,11 +152,19 @@ filter_search_results (HdyActionRow         *row,
     priv->n_last_search_results++;
     gtk_widget_show (GTK_WIDGET (row));
 
+    g_free (subtitle);
+    g_free (title);
+    g_free (text);
+
     return TRUE;
   }
 
   gtk_widget_hide (GTK_WIDGET (row));
 
+  g_free (subtitle);
+  g_free (title);
+  g_free (text);
+
   return FALSE;
 }
 
@@ -194,8 +205,10 @@ new_search_row_for_preference (HdyPreferencesRow    *row,
   if (group_title && !hdy_view_switcher_title_get_title_visible (priv->view_switcher_title))
     hdy_action_row_set_subtitle (widget, group_title);
   if (group_title) {
-    g_autofree gchar *subtitle = g_strdup_printf ("%s → %s", page_title != NULL ? page_title : _("Untitled 
page"), group_title);
+    gchar *subtitle = g_strdup_printf ("%s → %s", page_title != NULL ? page_title : _("Untitled page"), 
group_title);
     hdy_action_row_set_subtitle (widget, subtitle);
+
+    g_free (subtitle);
   } else if (page_title)
     hdy_action_row_set_subtitle (widget, page_title);
 
@@ -211,7 +224,7 @@ static void
 update_search_results (HdyPreferencesWindow *self)
 {
   HdyPreferencesWindowPrivate *priv = hdy_preferences_window_get_instance_private (self);
-  g_autoptr (GListStore) model;
+  GListStore *model;
 
   model = g_list_store_new (HDY_TYPE_PREFERENCES_ROW);
   gtk_container_foreach (GTK_CONTAINER (priv->pages_stack), (GtkCallback) 
hdy_preferences_page_add_preferences_to_model, model);
@@ -219,6 +232,8 @@ update_search_results (HdyPreferencesWindow *self)
   for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model)); i++)
     gtk_container_add (GTK_CONTAINER (priv->search_results),
                        new_search_row_for_preference ((HdyPreferencesRow *) g_list_model_get_item 
(G_LIST_MODEL (model), i), self));
+
+  g_object_unref (model);
 }
 
 static void
diff --git a/src/hdy-settings.c b/src/hdy-settings.c
index 3845c4bd..b97bc590 100644
--- a/src/hdy-settings.c
+++ b/src/hdy-settings.c
@@ -298,8 +298,8 @@ static void
 init_gsettings (HdySettings *self)
 {
   GSettingsSchemaSource *source;
-  g_autoptr (GSettingsSchema) schema = NULL;
-  g_autoptr (GSettingsSchema) a11y_schema = NULL;
+  GSettingsSchema *schema = NULL;
+  GSettingsSchema *a11y_schema = NULL;
 
 #ifndef G_OS_WIN32
   /* While we can access gsettings in flatpak, we can't do anything useful with
@@ -337,6 +337,9 @@ init_gsettings (HdySettings *self)
                               G_CALLBACK (gsettings_high_contrast_changed_cb),
                               self);
   }
+
+  g_settings_schema_unref (a11y_schema);
+  g_settings_schema_unref (schema);
 }
 
 /* Legacy */
@@ -344,7 +347,8 @@ init_gsettings (HdySettings *self)
 static gboolean
 is_theme_high_contrast (void)
 {
-  g_autofree gchar *icon_theme_name = NULL;
+  gchar *icon_theme_name = NULL;
+  gboolean result;
 
   /* We're using icon theme here as we control gtk-theme-name and it
    * interferes with the notifications. */
@@ -352,8 +356,12 @@ is_theme_high_contrast (void)
                 "gtk-icon-theme-name", &icon_theme_name,
                 NULL);
 
-  return !g_strcmp0 (icon_theme_name, "HighContrast") ||
-         !g_strcmp0 (icon_theme_name, "HighContrastInverse");
+  result =  !g_strcmp0 (icon_theme_name, "HighContrast") ||
+            !g_strcmp0 (icon_theme_name, "HighContrastInverse");
+
+  g_free (icon_theme_name);
+
+  return result;
 }
 
 static void
diff --git a/src/hdy-shadow-helper.c b/src/hdy-shadow-helper.c
index 03d83a33..37ceab00 100644
--- a/src/hdy-shadow-helper.c
+++ b/src/hdy-shadow-helper.c
@@ -62,7 +62,7 @@ create_context (HdyShadowHelper *self,
                 const gchar     *name,
                 GtkPanDirection  direction)
 {
-  g_autoptr(GtkWidgetPath) path = NULL;
+  GtkWidgetPath *path = NULL;
   GtkStyleContext *context;
   gint pos;
   const gchar *direction_name;
@@ -81,6 +81,7 @@ create_context (HdyShadowHelper *self,
   context = gtk_style_context_new ();
   gtk_style_context_set_path (context, path);
 
+  gtk_widget_path_unref (path);
   g_type_class_unref (enum_class);
 
   return context;
@@ -118,9 +119,9 @@ create_element_pattern (GtkStyleContext *context,
                         gint             height,
                         gint             scale)
 {
-  g_autoptr (cairo_surface_t) surface =
+  cairo_surface_t *surface =
     cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width * scale, height * scale);
-  g_autoptr (cairo_t) cr = cairo_create (surface);
+  cairo_t *cr = cairo_create (surface);
   cairo_pattern_t *pattern;
 
   cairo_surface_set_device_scale (surface, scale, scale);
@@ -130,6 +131,9 @@ create_element_pattern (GtkStyleContext *context,
 
   pattern = cairo_pattern_create_for_surface (surface);
 
+  cairo_destroy (cr);
+  cairo_surface_destroy (surface);
+
   return pattern;
 }
 
@@ -139,10 +143,10 @@ cache_shadow (HdyShadowHelper *self,
               gint             height,
               GtkPanDirection  direction)
 {
-  g_autoptr(GtkStyleContext) dim_context = NULL;
-  g_autoptr(GtkStyleContext) shadow_context = NULL;
-  g_autoptr(GtkStyleContext) border_context = NULL;
-  g_autoptr(GtkStyleContext) outline_context = NULL;
+  GtkStyleContext *dim_context = NULL;
+  GtkStyleContext *shadow_context = NULL;
+  GtkStyleContext *border_context = NULL;
+  GtkStyleContext *outline_context = NULL;
   gint shadow_size, border_size, outline_size, scale;
 
   scale = gtk_widget_get_scale_factor (self->widget);
@@ -185,6 +189,11 @@ cache_shadow (HdyShadowHelper *self,
   self->last_width = width;
   self->last_height = height;
   self->last_scale = scale;
+
+  g_object_unref (outline_context);
+  g_object_unref (border_context);
+  g_object_unref (shadow_context);
+  g_object_unref (dim_context);
 }
 
 static void
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index 7ebeb66f..2ec9c324 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -2302,7 +2302,7 @@ void
 hdy_stackable_box_remove (HdyStackableBox *self,
                           GtkWidget       *widget)
 {
-  g_autoptr (HdyStackableBoxChildInfo) child_info = find_child_info_for_widget (self, widget);
+  HdyStackableBoxChildInfo *child_info = find_child_info_for_widget (self, widget);
   gboolean contains_child = child_info != NULL;
 
   g_return_if_fail (contains_child);
@@ -2326,6 +2326,8 @@ hdy_stackable_box_remove (HdyStackableBox *self,
   unregister_window (self, child_info);
 
   gtk_widget_unparent (widget);
+
+  free_child_info (child_info);
 }
 
 void
@@ -2338,7 +2340,7 @@ hdy_stackable_box_forall (HdyStackableBox *self,
    * looping through it, for example by calling hdy_stackable_box_remove() on all
    * children when destroying the HdyStackableBox_private_offset.
    */
-  g_autoptr (GList) children_copy = g_list_copy (self->children);
+  GList *children_copy = g_list_copy (self->children);
   GList *children;
   HdyStackableBoxChildInfo *child_info;
 
@@ -2351,6 +2353,8 @@ hdy_stackable_box_forall (HdyStackableBox *self,
   g_list_free (self->children_reversed);
   self->children_reversed = g_list_copy (self->children);
   self->children_reversed = g_list_reverse (self->children_reversed);
+
+  g_list_free (children_copy);
 }
 
 static void
diff --git a/src/hdy-style-manager.c b/src/hdy-style-manager.c
index f18d4996..2e6ef3fc 100644
--- a/src/hdy-style-manager.c
+++ b/src/hdy-style-manager.c
@@ -108,8 +108,8 @@ find_theme_dir (const gchar *dir,
                 const gchar *name,
                 const gchar *variant)
 {
-  g_autofree gchar *file = NULL;
-  g_autofree gchar *base = NULL;
+  gchar *file = NULL;
+  gchar *base = NULL;
   gchar *path;
   gint i;
 
@@ -124,7 +124,7 @@ find_theme_dir (const gchar *dir,
     base = g_build_filename (dir, name, NULL);
 
   for (i = MINOR; i >= 0; i = i - 2) {
-    g_autofree gchar *subsubdir = NULL;
+    gchar *subsubdir = NULL;
 
     if (i < 14)
       i = 0;
@@ -132,6 +132,8 @@ find_theme_dir (const gchar *dir,
     subsubdir = g_strdup_printf ("gtk-3.%d", i);
     path = g_build_filename (base, subsubdir, file, NULL);
 
+    g_free (subsubdir);
+
     if (g_file_test (path, G_FILE_TEST_EXISTS))
       break;
 
@@ -139,6 +141,9 @@ find_theme_dir (const gchar *dir,
     path = NULL;
   }
 
+  g_free (base);
+  g_free (file);
+
   return path;
 }
 
@@ -148,7 +153,7 @@ static gchar *
 find_theme (const gchar *name,
             const gchar *variant)
 {
-  g_autofree gchar *dir = NULL;
+  gchar *dir = NULL;
   const gchar *const *dirs;
   gchar *path;
   gint i;
@@ -175,6 +180,8 @@ find_theme (const gchar *name,
   dir = get_theme_dir ();
   path = find_theme_dir (dir, NULL, name, variant);
 
+  g_free (dir);
+
   return path;
 }
 
@@ -182,8 +189,9 @@ static gboolean
 check_theme_exists (const gchar *name,
                     const gchar *variant)
 {
-  g_autofree gchar *resource_path = NULL;
-  g_autofree gchar *path = NULL;
+  gchar *resource_path = NULL;
+  gchar *path = NULL;
+  gboolean result;
 
   /* try loading the resource for the theme. This is mostly meant for built-in
    * themes.
@@ -194,33 +202,48 @@ check_theme_exists (const gchar *name,
     resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk.css", name);
 
   if (g_resources_get_info (resource_path, 0, NULL, NULL, NULL))
-    return TRUE;
+    result = TRUE;
 
   /* Next try looking for files in the various theme directories. */
   path = find_theme (name, variant);
 
-  return path != NULL;
+  result = path != NULL;
+
+  g_free (resource_path);
+  g_free (path);
+
+  return result;
 }
 
 static gchar *
 get_system_theme_name (void)
 {
   GdkScreen *screen = gdk_screen_get_default ();
-  g_auto (GValue) value = G_VALUE_INIT;
+  GValue value = G_VALUE_INIT;
+  gchar *result;
 
   g_value_init (&value, G_TYPE_STRING);
   if (!gdk_screen_get_setting (screen, "gtk-theme-name", &value))
-    return g_strdup ("Adwaita");
+    result = g_strdup ("Adwaita");
+  else
+    result = g_value_dup_string (&value);
+
+  g_value_unset (&value);
 
-  return g_value_dup_string (&value);
+  return result;
 }
 
 static gboolean
 check_current_theme_exists (gboolean dark)
 {
-  g_autofree gchar *theme_name = get_system_theme_name ();
+  gchar *theme_name = get_system_theme_name ();
+  gboolean result;
+
+  result = check_theme_exists (theme_name, dark ? "dark" : NULL);
 
-  return check_theme_exists (theme_name, dark ? "dark" : NULL);
+  g_free (theme_name);
+
+  return result;
 }
 
 static void
@@ -648,7 +671,7 @@ static void
 hdy_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)
@@ -669,6 +692,8 @@ hdy_style_manager_ensure (void)
                     "display-opened",
                     G_CALLBACK (register_display),
                     NULL);
+
+  g_slist_free (displays);
 }
 
 /**
diff --git a/src/hdy-swipe-tracker.c b/src/hdy-swipe-tracker.c
index ba01bd05..43beeceb 100644
--- a/src/hdy-swipe-tracker.c
+++ b/src/hdy-swipe-tracker.c
@@ -201,13 +201,15 @@ get_range (HdySwipeTracker *self,
            gdouble         *first,
            gdouble         *last)
 {
-  g_autofree gdouble *points = NULL;
+  gdouble *points = NULL;
   gint n;
 
   points = hdy_swipeable_get_snap_points (self->swipeable, &n);
 
   *first = points[0];
   *last = points[n - 1];
+
+  g_free (points);
 }
 
 static void
@@ -241,7 +243,7 @@ gesture_prepare (HdySwipeTracker        *self,
 static void
 trim_history (HdySwipeTracker *self)
 {
-  g_autoptr (GdkEvent) event = gtk_get_current_event ();
+  GdkEvent *event = gtk_get_current_event ();
   guint32 threshold_time = gdk_event_get_time (event) - EVENT_HISTORY_THRESHOLD_MS;
   guint i;
 
@@ -255,13 +257,15 @@ trim_history (HdySwipeTracker *self)
 
   if (i > 0)
     g_array_remove_range (self->event_history, 0, i);
+
+  gdk_event_free (event);
 }
 
 static void
 append_to_history (HdySwipeTracker *self,
                    gdouble          delta)
 {
-  g_autoptr (GdkEvent) event = gtk_get_current_event ();
+  GdkEvent *event = gtk_get_current_event ();
   EventHistoryRecord record;
 
   trim_history (self);
@@ -270,6 +274,8 @@ append_to_history (HdySwipeTracker *self,
   record.time = gdk_event_get_time (event);
 
   g_array_append_val (self->event_history, record);
+
+  gdk_event_free (event);
 }
 
 static gdouble
@@ -400,11 +406,13 @@ gesture_update (HdySwipeTracker *self,
     return;
 
   if (!self->allow_long_swipes) {
-    g_autofree gdouble *points = NULL;
+    gdouble *points = NULL;
     gint n;
 
     points = hdy_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);
   }
@@ -423,7 +431,7 @@ get_end_progress (HdySwipeTracker *self,
                   gboolean         is_touchpad)
 {
   gdouble pos, decel, slope;
-  g_autofree gdouble *points = NULL;
+  gdouble *points = NULL;
   gint n;
   gdouble lower, upper;
 
@@ -432,8 +440,13 @@ get_end_progress (HdySwipeTracker *self,
 
   points = hdy_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)];
+  if (ABS (velocity) < (is_touchpad ? VELOCITY_THRESHOLD_TOUCHPAD : VELOCITY_THRESHOLD_TOUCH)) {
+    double result = points[find_closest_point (points, n, self->progress)];
+
+    g_free (points);
+
+    return result;
+  }
 
   decel = is_touchpad ? DECELERATION_TOUCHPAD : DECELERATION_TOUCH;
   slope = decel / (1.0 - decel) / 1000.0;
@@ -461,6 +474,8 @@ get_end_progress (HdySwipeTracker *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/hdy-tab-view.c b/src/hdy-tab-view.c
index c69f8e6b..ef3fa9b5 100644
--- a/src/hdy-tab-view.c
+++ b/src/hdy-tab-view.c
@@ -760,7 +760,7 @@ insert_page (HdyTabView *self,
              gint        position,
              gboolean    pinned)
 {
-  g_autoptr (HdyTabPage) page =
+  HdyTabPage *page =
     g_object_new (HDY_TYPE_TAB_PAGE,
                   "child", child,
                   "parent", parent,
@@ -773,6 +773,8 @@ insert_page (HdyTabView *self,
   if (!self->selected_page)
     hdy_tab_view_set_selected_page (self, page);
 
+  g_object_unref (page);
+
   return page;
 }
 
@@ -2421,7 +2423,7 @@ HdyTabPage *
 hdy_tab_view_get_nth_page (HdyTabView *self,
                            gint        position)
 {
-  g_autoptr (HdyTabPage) page = NULL;
+  HdyTabPage *page = NULL;
 
   g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
   g_return_val_if_fail (position >= 0, NULL);
@@ -2429,6 +2431,8 @@ hdy_tab_view_get_nth_page (HdyTabView *self,
 
   page = g_list_model_get_item (G_LIST_MODEL (self->pages), (guint) position);
 
+  g_object_unref (page);
+
   return page;
 }
 
diff --git a/src/hdy-window-handle-controller.c b/src/hdy-window-handle-controller.c
index d6687451..a5dca519 100644
--- a/src/hdy-window-handle-controller.c
+++ b/src/hdy-window-handle-controller.c
@@ -324,7 +324,7 @@ titlebar_action (HdyWindowHandleController *self,
                  guint                      button)
 {
   GtkSettings *settings;
-  g_autofree gchar *action = NULL;
+  gchar *action = NULL;
   GtkWindow *window = get_window (self);
 
   if (!window)
@@ -349,11 +349,11 @@ titlebar_action (HdyWindowHandleController *self,
     g_assert_not_reached ();
   }
 
-  if (action == NULL)
-    return FALSE;
+  if (action == NULL || g_str_equal (action, "none")){
+    g_free (action);
 
-  if (g_str_equal (action, "none"))
     return FALSE;
+  }
 
   if (g_str_has_prefix (action, "toggle-maximize")) {
     /*
@@ -365,29 +365,39 @@ titlebar_action (HdyWindowHandleController *self,
         gtk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_NORMAL)
           hdy_gtk_window_toggle_maximized (window);
 
+    g_free (action);
+
     return TRUE;
   }
 
   if (g_str_equal (action, "lower")) {
     gdk_window_lower (gtk_widget_get_window (GTK_WIDGET (window)));
 
+    g_free (action);
+
     return TRUE;
   }
 
   if (g_str_equal (action, "minimize")) {
     gdk_window_iconify (gtk_widget_get_window (GTK_WIDGET (window)));
 
+    g_free (action);
+
     return TRUE;
   }
 
   if (g_str_equal (action, "menu")) {
     do_popup (self, (GdkEventButton*) event);
 
+    g_free (action);
+
     return TRUE;
   }
 
   g_warning ("Unsupported titlebar action %s", action);
 
+  g_free (action);
+
   return FALSE;
 }
 
diff --git a/src/hdy-window-mixin.c b/src/hdy-window-mixin.c
index fd0d1e90..2bb3d952 100644
--- a/src/hdy-window-mixin.c
+++ b/src/hdy-window-mixin.c
@@ -78,7 +78,7 @@ update_child_context (HdyWindowMixin  *self,
                       GtkStyleContext *context,
                       const gchar     *name)
 {
-  g_autoptr (GtkWidgetPath) path = gtk_widget_path_new ();
+  GtkWidgetPath *path = gtk_widget_path_new ();
   GtkStyleContext *parent = gtk_widget_get_style_context (GTK_WIDGET (self->window));
   gint position;
 
@@ -88,6 +88,8 @@ update_child_context (HdyWindowMixin  *self,
 
   gtk_style_context_set_path (context, path);
   gtk_style_context_set_state (context, gtk_style_context_get_state (parent));
+
+  gtk_widget_path_unref (path);
 }
 
 static void
@@ -215,7 +217,7 @@ create_masks (HdyWindowMixin *self,
     return;
 
   for (i = 0; i < HDY_N_CORNERS; i++) {
-    g_autoptr (cairo_t) mask_cr = NULL;
+    cairo_t *mask_cr = NULL;
 
     self->masks[i] =
       cairo_surface_create_similar_image (cairo_get_target (cr),
@@ -233,6 +235,8 @@ create_masks (HdyWindowMixin *self,
                r,
                0, G_PI * 2);
     cairo_fill (mask_cr);
+
+    cairo_destroy (mask_cr);
   }
 }
 
@@ -348,8 +352,8 @@ hdy_window_mixin_draw (HdyWindowMixin *self,
     GdkRectangle clip = { 0 };
     gint width, height, x, y, w, h, r, scale_factor;
     GtkWidget *titlebar;
-    g_autoptr (cairo_surface_t) surface = NULL;
-    g_autoptr (cairo_t) surface_cr = NULL;
+    cairo_surface_t *surface = NULL;
+    cairo_t *surface_cr = NULL;
     GtkBorder shadow;
 
     /* Use the parent drawing unless we have a reason to use masking */
@@ -456,6 +460,9 @@ hdy_window_mixin_draw (HdyWindowMixin *self,
     }
 
     cairo_restore (cr);
+
+    cairo_destroy (surface_cr);
+    cairo_surface_destroy (surface);
   }
 
   data.self = self;


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