From 06fbad0b26caed764d862f51d0c12b12fa776b30 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Nov 2020 09:05:55 -0500 Subject: [PATCH 1/6] wayland: Plug listmodel memory leaks We were leaking references returned from g_list_model_get_item in some places. --- gdk/wayland/gdksurface-wayland.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index df106ee6e3..73c59779ff 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -1270,6 +1270,7 @@ configure_surface_geometry (GdkSurface *surface) monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0); gdk_monitor_get_geometry (monitor, &monitor_geometry); + g_object_unref (monitor); bounds_width = monitor_geometry.width; bounds_height = monitor_geometry.height; From 7e089664fc4f5c166007cf603bbbfcd707ab2f19 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Nov 2020 09:06:37 -0500 Subject: [PATCH 2/6] win32: Plug listmodel memory leaks We were leaking references returned from g_list_model_get_item in some places. --- gdk/win32/gdksurface-win32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 2ca4a670af..1f76b5bbb3 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -1982,6 +1982,7 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context) GdkMonitor *monitor; monitor = g_list_model_get_item (monitors, monitor_idx); + g_object_unref (monitor); gdk_win32_monitor_get_workarea (monitor, &wa); gdk_monitor_get_geometry (monitor, &geometry); From d63afaf5ad93bd39ce33355a1035c4653e5ed1e5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Nov 2020 09:07:01 -0500 Subject: [PATCH 3/6] x11: Plug listmodel memory leaks We were leaking references returned from g_list_model_get_item in some places. --- gdk/x11/gdkscreen-x11.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index 672165412e..9cb8be6746 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -613,10 +613,8 @@ init_randr15 (GdkX11Screen *x11_screen) notify_surface_monitor_change (x11_display, GDK_MONITOR (monitor)); if (monitor->remove) { - g_object_ref (monitor); g_list_store_remove (x11_display->monitors, i); gdk_monitor_invalidate (GDK_MONITOR (monitor)); - g_object_unref (monitor); } g_object_unref (monitor); } @@ -764,11 +762,10 @@ init_randr13 (GdkX11Screen *x11_screen) notify_surface_monitor_change (x11_display, GDK_MONITOR (monitor)); if (monitor->remove) { - g_object_ref (monitor); g_list_store_remove (x11_display->monitors, i); gdk_monitor_invalidate (GDK_MONITOR (monitor)); - g_object_unref (monitor); } + g_object_unref (monitor); } x11_display->primary_monitor = 0; @@ -852,10 +849,8 @@ init_no_multihead (GdkX11Screen *x11_screen) notify_surface_monitor_change (x11_display, GDK_MONITOR (monitor)); if (monitor->remove) { - g_object_ref (monitor); g_list_store_remove (x11_display->monitors, i); gdk_monitor_invalidate (GDK_MONITOR (monitor)); - g_object_unref (monitor); } g_object_unref (monitor); } From 6079033cde3914a01d2c5849dcc1bb428f3a287c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Nov 2020 09:07:22 -0500 Subject: [PATCH 4/6] columnview: Plug listmodel memory leaks We were leaking references returned from g_list_model_get_item in some places. --- gtk/gtkcolumnview.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c index d39b50e875..afa5150269 100644 --- a/gtk/gtkcolumnview.c +++ b/gtk/gtkcolumnview.c @@ -983,6 +983,8 @@ header_drag_begin (GtkGestureDrag *gesture, break; } + + g_object_unref (column); } for (i = 0; !self->in_column_resize && i < n; i++) @@ -1049,7 +1051,10 @@ header_drag_end (GtkGestureDrag *gesture, sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence)) - return; + { + g_object_unref (column); + return; + } for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (self->columns)); i++) { @@ -1531,7 +1536,6 @@ gtk_column_view_remove_column (GtkColumnView *self, g_object_unref (item); if (item == column) break; - } gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (self->sorter), column); From 6cbd7e29ddeb0e2a428cdd42e0d878ab6a127454 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Nov 2020 09:07:40 -0500 Subject: [PATCH 5/6] fontchooser: Plug listmodel memory leaks We were leaking references returned from g_list_model_get_item in some places. --- gtk/gtkfontchooserwidget.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index 254752f84d..62b0320049 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -1368,11 +1368,14 @@ gtk_font_chooser_widget_ensure_matching_selection (GtkFontChooserWidget *self) n = g_list_model_get_n_items (G_LIST_MODEL (self->selection)); for (i = 0; i < n; i++) { - gpointer item = g_list_model_get_item (G_LIST_MODEL (self->selection), i); + gpointer item; PangoFontFace *face; PangoFontFamily *family; PangoFontDescription *merged; + item = g_list_model_get_item (G_LIST_MODEL (self->selection), i); + g_object_unref (item); + if (PANGO_IS_FONT_FAMILY (item)) { family = item; @@ -1384,14 +1387,10 @@ gtk_font_chooser_widget_ensure_matching_selection (GtkFontChooserWidget *self) family = pango_font_face_get_family (face); } if (!my_pango_font_family_equal (desc_family, pango_font_family_get_name (family))) - { - g_object_unref (face); - continue; - } + continue; merged = pango_font_face_describe (face); pango_font_description_merge_static (merged, self->font_desc, FALSE); - g_object_unref (face); if (pango_font_description_equal (merged, self->font_desc)) { From c442f9f05a2e4831ac520fbacbd76348ccd1a04d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Nov 2020 09:07:54 -0500 Subject: [PATCH 6/6] printdialog: Plug listmodel memory leaks We were leaking references returned from g_list_model_get_item in some places. --- gtk/gtkpagesetupunixdialog.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c index 8cc9768a5a..ea61efd367 100644 --- a/gtk/gtkpagesetupunixdialog.c +++ b/gtk/gtkpagesetupunixdialog.c @@ -702,6 +702,8 @@ paper_size_changed (GtkDropDown *combo_box, g_signal_connect (custom_paper_dialog, "response", G_CALLBACK (custom_paper_dialog_response_cb), dialog); gtk_window_present (GTK_WINDOW (custom_paper_dialog)); + g_object_unref (page_setup); + return; }