@@ -90,6 +90,7 @@ static void avif_animation_finalize(GObject * obj)
90
90
g_thread_join (context -> decoder_thread );
91
91
g_async_queue_unref (context -> queue );
92
92
g_object_unref (context );
93
+ context = NULL ;
93
94
}
94
95
95
96
static gboolean avif_animation_is_static_image (GdkPixbufAnimation * animation )
@@ -152,7 +153,7 @@ static gboolean avif_animation_iter_advance(GdkPixbufAnimationIter * iter, const
152
153
size_t prev_frame = avif_iter -> current_frame ;
153
154
uint64_t elapsed_time = current_time -> tv_sec * 1000 + current_time -> tv_usec / 1000 - avif_iter -> time_offset ;
154
155
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 ) ) {
156
157
avif_iter -> current_frame = context -> decoder -> imageCount - 1 ;
157
158
} else {
158
159
@@ -174,10 +175,9 @@ static gboolean avif_animation_iter_advance(GdkPixbufAnimationIter * iter, const
174
175
}
175
176
/* only relevant for animations that fit in the buffer */
176
177
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 ;
179
179
avif_iter -> current_animation_time = 0 ;
180
- avif_iter -> current_frame = 0 ;
180
+ avif_iter -> current_frame = 0 ;
181
181
}
182
182
183
183
/* how much time has elapsed since the last frame */
@@ -221,9 +221,11 @@ static gboolean avif_animation_iter_on_currently_loading_frame(GdkPixbufAnimatio
221
221
222
222
static void avif_animation_iter_finalize (GObject * obj )
223
223
{
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 ;
227
229
}
228
230
229
231
0 commit comments