Skip to content

Commit

Permalink
Remove unref and fix repeat count.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiers committed May 14, 2023
1 parent 7efaada commit 025423d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions contrib/gdk-pixbuf/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static void avif_animation_finalize(GObject * obj)
g_thread_join(context->decoder_thread);
g_async_queue_unref(context->queue);
g_object_unref(context);
context = NULL;
}

static gboolean avif_animation_is_static_image(GdkPixbufAnimation * animation)
Expand Down Expand Up @@ -152,7 +153,7 @@ static gboolean avif_animation_iter_advance(GdkPixbufAnimationIter * iter, const
size_t prev_frame = avif_iter->current_frame;
uint64_t elapsed_time = current_time->tv_sec * 1000 + current_time->tv_usec / 1000 - avif_iter->time_offset;

if (context->decoder->repetitionCount > 0 && elapsed_time > context->total_animation_time * context->decoder->repetitionCount) {
if (context->decoder->repetitionCount > 0 && elapsed_time > context->total_animation_time * (context->decoder->repetitionCount + 1)) {
avif_iter->current_frame = context->decoder->imageCount - 1;
} else {

Expand All @@ -174,10 +175,9 @@ static gboolean avif_animation_iter_advance(GdkPixbufAnimationIter * iter, const
}
/* only relevant for animations that fit in the buffer */
else if (elapsed_time > context->total_animation_time) {
avif_iter->time_offset += context->total_animation_time;
elapsed_time = elapsed_time - context->total_animation_time;
elapsed_time = elapsed_time % context->total_animation_time;
avif_iter->current_animation_time = 0;
avif_iter->current_frame = 0 ;
avif_iter->current_frame = 0;
}

/* how much time has elapsed since the last frame */
Expand Down Expand Up @@ -221,9 +221,11 @@ static gboolean avif_animation_iter_on_currently_loading_frame(GdkPixbufAnimatio

static void avif_animation_iter_finalize(GObject * obj)
{
AvifAnimationIter * iter = (AvifAnimationIter *)obj;
g_object_unref(iter->animation);
g_object_unref(iter);
/*
* do nothing, as according to documentation, the caller of gdk_pixbuf_get_iter:
* "takes ownership of the data, and is responsible for freeing it"
*/
(void)obj;
}


Expand Down

0 comments on commit 025423d

Please sign in to comment.