Skip to content

Commit 025423d

Browse files
committed
Remove unref and fix repeat count.
1 parent 7efaada commit 025423d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

contrib/gdk-pixbuf/loader.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static void avif_animation_finalize(GObject * obj)
9090
g_thread_join(context->decoder_thread);
9191
g_async_queue_unref(context->queue);
9292
g_object_unref(context);
93+
context = NULL;
9394
}
9495

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

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

@@ -174,10 +175,9 @@ static gboolean avif_animation_iter_advance(GdkPixbufAnimationIter * iter, const
174175
}
175176
/* only relevant for animations that fit in the buffer */
176177
else if (elapsed_time > context->total_animation_time) {
177-
avif_iter->time_offset += context->total_animation_time;
178-
elapsed_time = elapsed_time - context->total_animation_time;
178+
elapsed_time = elapsed_time % context->total_animation_time;
179179
avif_iter->current_animation_time = 0;
180-
avif_iter->current_frame = 0 ;
180+
avif_iter->current_frame = 0;
181181
}
182182

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

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

229231

0 commit comments

Comments
 (0)