fixed possible crash
authorVladimir Nadvornik <nadvornik@suse.cz>
Fri, 23 Jan 2009 22:53:02 +0000 (22:53 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Fri, 23 Jan 2009 22:53:02 +0000 (22:53 +0000)
src/image.c

index b50b710..0e98cb5 100644 (file)
@@ -1003,6 +1003,10 @@ void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gint
        gint read_exif_for_color_profile = (imd->color_profile_enable && imd->color_profile_use_image);
        gint read_exif_for_orientation = FALSE;
 
+       /* read_exif and similar functions can actually notice that the file has changed and triger a notification
+       that removes the pixbuf from cache and unref it. Therefore we must ref it here before it is taken over by the renderer. */
+       g_object_ref(pixbuf); 
+       
        if (imd->image_fd && imd->image_fd->user_orientation)
                imd->orientation = imd->image_fd->user_orientation;
        else if (options->image.exif_rotate_enable)
@@ -1041,6 +1045,8 @@ void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gint
                pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
                }
 
+       g_object_unref(pixbuf);
+
        if (imd->color_profile_enable)
                {
                if (!image_post_process_color(imd, 0, exif, FALSE))