[gtk+] progresstracker: Don't hand out NaN
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] progresstracker: Don't hand out NaN
- Date: Sun, 12 Nov 2017 05:22:52 +0000 (UTC)
commit b47ff72ebc626180fc14459a66fd06e64fedcdb2
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 12 06:19:00 2017 +0100
progresstracker: Don't hand out NaN
When the duration is set to 0, clamp it to 1us. This way we're almost
correct: We should really instantly finish, but we don't. But we do
respect the delay.
Doing this properly would require some refactoring of how the progress
tracker actually maintains progress, and this is just a quick fix.
gtk/gtkprogresstracker.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkprogresstracker.c b/gtk/gtkprogresstracker.c
index 81cca35..0ddcbfb 100644
--- a/gtk/gtkprogresstracker.c
+++ b/gtk/gtkprogresstracker.c
@@ -82,7 +82,7 @@ gtk_progress_tracker_start (GtkProgressTracker *tracker,
tracker->is_running = TRUE;
tracker->last_frame_time = 0;
tracker->duration = duration;
- tracker->iteration = - delay / (gdouble) duration;
+ tracker->iteration = - delay / (gdouble) MAX (duration, 1);
tracker->iteration_count = iteration_count;
}
@@ -108,7 +108,7 @@ gtk_progress_tracker_finish (GtkProgressTracker *tracker)
**/
void
gtk_progress_tracker_advance_frame (GtkProgressTracker *tracker,
- guint64 frame_time)
+ guint64 frame_time)
{
gdouble delta;
@@ -127,7 +127,7 @@ gtk_progress_tracker_advance_frame (GtkProgressTracker *tracker,
return;
}
- delta = (frame_time - tracker->last_frame_time) / gtk_slowdown / tracker->duration;
+ delta = (frame_time - tracker->last_frame_time) / gtk_slowdown / MAX (tracker->duration, 1);
tracker->last_frame_time = frame_time;
tracker->iteration += delta;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]