From 611ed7767965625a0869000332100c50d83bf400 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 2 Mar 2020 16:19:49 +0100 Subject: Clean up image on destruction of CrystFELImageView --- src/crystfelimageview.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/crystfelimageview.c') diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c index 4fd2a97c..566594d8 100644 --- a/src/crystfelimageview.c +++ b/src/crystfelimageview.c @@ -75,8 +75,28 @@ static void redraw(CrystFELImageView *iv) } +static void cleanup_image(CrystFELImageView *iv) +{ + int i; + + if ( iv->image != NULL ) { + if ( (iv->image->detgeom != NULL) && (iv->pixbufs != NULL) ) { + for ( i=0; iimage->detgeom->n_panels; i++ ) { + if ( iv->pixbufs[i] != NULL ) { + gdk_pixbuf_unref(iv->pixbufs[i]); + } + } + } + image_free(iv->image); + } +} + + static gint destroy_sig(GtkWidget *window, CrystFELImageView *iv) { + cleanup_image(iv); + free(iv->filename); + free(iv->event); return FALSE; } @@ -456,7 +476,6 @@ static void detgeom_pixel_extents(struct detgeom *det, static int reload_image(CrystFELImageView *iv) { - int i; int n_pb; double min_x, min_y, max_x, max_y; double border; @@ -464,17 +483,7 @@ static int reload_image(CrystFELImageView *iv) if ( iv->dtempl == NULL ) return 0; if ( iv->filename == NULL ) return 0; - /* Free old stuff */ - if ( iv->image != NULL ) { - if ( (iv->image->detgeom != NULL) && (iv->pixbufs != NULL) ) { - for ( i=0; iimage->detgeom->n_panels; i++ ) { - if ( iv->pixbufs[i] != NULL ) { - gdk_pixbuf_unref(iv->pixbufs[i]); - } - } - } - image_free(iv->image); - } + cleanup_image(iv); iv->image = image_read(iv->dtempl, iv->filename, iv->event); if ( iv->image == NULL ) return 1; -- cgit v1.2.3