diff options
author | Thomas White <taw@physics.org> | 2020-03-02 16:19:49 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:42:24 +0200 |
commit | 611ed7767965625a0869000332100c50d83bf400 (patch) | |
tree | d87369d453b67a5436763c0fa4c301ab7e2a74fb /src | |
parent | 49ae24384b483e40a6f1ad266ee0828c8f5c5a04 (diff) |
Clean up image on destruction of CrystFELImageView
Diffstat (limited to 'src')
-rw-r--r-- | src/crystfelimageview.c | 33 |
1 files changed, 21 insertions, 12 deletions
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; i<iv->image->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; i<iv->image->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; |