From fee901a5901d4bbacbf3ce90bcc3321a5c5e721e Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Tue, 23 Nov 2021 17:12:31 +0100 Subject: Improve memory management --- fastiv-browser.c | 6 ++---- fastiv.c | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fastiv-browser.c b/fastiv-browser.c index f130473..0ed8c50 100644 --- a/fastiv-browser.c +++ b/fastiv-browser.c @@ -73,8 +73,7 @@ static void entry_free(Entry *self) { g_free(self->filename); - if (self->thumbnail) - cairo_surface_destroy(self->thumbnail); + g_clear_pointer(&self->thumbnail, cairo_surface_destroy); g_clear_object(&self->icon); } @@ -349,8 +348,7 @@ entry_add_thumbnail(gpointer data, gpointer user_data) { Entry *self = data; g_clear_object(&self->icon); - if (self->thumbnail) - cairo_surface_destroy(self->thumbnail); + g_clear_pointer(&self->thumbnail, cairo_surface_destroy); FastivBrowser *browser = FASTIV_BROWSER(user_data); self->thumbnail = rescale_thumbnail( diff --git a/fastiv.c b/fastiv.c index 880d91f..5aabd46 100644 --- a/fastiv.c +++ b/fastiv.c @@ -425,7 +425,7 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, switch (event->keyval) { case GDK_KEY_Escape: case GDK_KEY_q: - gtk_main_quit(); + gtk_widget_destroy(g.window); return TRUE; case GDK_KEY_o: @@ -598,6 +598,7 @@ main(int argc, char *argv[]) gtk_css_provider_load_from_data(provider, style, strlen(style), NULL); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref(provider); g.view_scroller = gtk_scrolled_window_new(NULL, NULL); g.view = g_object_new(FASTIV_TYPE_VIEW, NULL); -- cgit v1.2.3-70-g09d2