From 278fbcbbb4bff06b7e8e4ea0d3700b8a725bba51 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 7 Aug 2020 02:49:41 +0200 Subject: [PATCH 1/3] demo: Don't crash when closing words demo Make sure the stringlist we're loading into doesn't go away. It'd be better to have a cancellable, but I'm lazy. --- demos/gtk-demo/listview_words.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/demos/gtk-demo/listview_words.c b/demos/gtk-demo/listview_words.c index 50e40adc20..350383a4da 100644 --- a/demos/gtk-demo/listview_words.c +++ b/demos/gtk-demo/listview_words.c @@ -65,6 +65,7 @@ read_lines_cb (GObject *object, { g_print ("Could not read data: %s\n", error->message); g_clear_error (&error); + g_object_unref (stringlist); return; } @@ -74,6 +75,7 @@ read_lines_cb (GObject *object, { if (size) gtk_string_list_take (stringlist, g_utf8_make_valid (buffer, size)); + g_object_unref (stringlist); return; } @@ -121,6 +123,7 @@ file_is_open_cb (GObject *file, { g_print ("Could not open file: %s\n", error->message); g_error_free (error); + g_object_unref (data); return; } @@ -134,7 +137,7 @@ load_file (GtkStringList *list, GFile *file) { gtk_string_list_splice (list, 0, g_list_model_get_n_items (G_LIST_MODEL (list)), NULL); - g_file_read_async (file, G_PRIORITY_HIGH_IDLE, NULL, file_is_open_cb, list); + g_file_read_async (file, G_PRIORITY_HIGH_IDLE, NULL, file_is_open_cb, g_object_ref (list)); } static void From 052962a76098a1bde15f6eaabc774b32f30299f2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 7 Aug 2020 02:50:19 +0200 Subject: [PATCH 2/3] treeview: Use gtk_snapshot_append_border() No need to construct the node manually. --- gtk/gtktreeview.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 0898adea77..98d9f40e5c 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -13156,19 +13156,15 @@ gtk_treeview_snapshot_border (GtkSnapshot *snapshot, const graphene_rect_t *rect) { GskRoundedRect rounded; - GskRenderNode *border_node; gsk_rounded_rect_init_from_rect (&rounded, rect, 0); #define BLACK { 0, 0, 0, 1 } - border_node = gsk_border_node_new (&rounded, - (float[4]) { 1, 1, 1, 1 }, - (GdkRGBA[4]) { BLACK, BLACK, BLACK, BLACK }); + gtk_snapshot_append_border (snapshot, + &rounded, + (float[4]) { 1, 1, 1, 1 }, + (GdkRGBA[4]) { BLACK, BLACK, BLACK, BLACK }); #undef BLACK - - gtk_snapshot_append_node (snapshot, border_node); - - gsk_render_node_unref (border_node); } /* KEEP IN SYNC WITH GTK_TREE_VIEW_BIN_EXPOSE */ From 8557aaf327c3979309403bb85ed5931fc0fc0b63 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 7 Aug 2020 02:53:21 +0200 Subject: [PATCH 3/3] demo: fix memleak --- demos/gtk-demo/listview_words.c | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/gtk-demo/listview_words.c b/demos/gtk-demo/listview_words.c index 350383a4da..1687f4c48e 100644 --- a/demos/gtk-demo/listview_words.c +++ b/demos/gtk-demo/listview_words.c @@ -177,6 +177,7 @@ do_listview_words (GtkWidget *do_widget) stringlist = gtk_string_list_new ((const char **) words); g_strfreev (words); } + g_object_unref (file); filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string")); filter_model = gtk_filter_list_model_new (G_LIST_MODEL (stringlist), filter);