]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- cope with backward system time jumps (#240691)
authormlichvar <mlichvar>
Mon, 21 May 2007 13:15:11 +0000 (13:15 +0000)
committermlichvar <mlichvar>
Mon, 21 May 2007 13:15:11 +0000 (13:15 +0000)
form.c
newt.spec

diff --git a/form.c b/form.c
index 12df1750cced5fe46d9dce5418e6f7bcdcadc0f1..075c13dfd97c393e6b82818de95cb1920b527410 100644 (file)
--- a/form.c
+++ b/form.c
@@ -942,16 +942,19 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
        if (form->timer) {
            /* Calculate when we next need to return with a timeout. Do
               this inside the loop in case a callback resets the timer. */
-           if (!form->lastTimeout.tv_sec && !form->lastTimeout.tv_usec)
-               gettimeofday(&form->lastTimeout, NULL);
+           gettimeofday(&now, 0);
+
+           if ((!form->lastTimeout.tv_sec && !form->lastTimeout.tv_usec) ||
+                   now.tv_sec < form->lastTimeout.tv_sec ||
+                   (now.tv_sec == form->lastTimeout.tv_sec &&
+                    now.tv_usec < form->lastTimeout.tv_usec))
+               form->lastTimeout = now;
 
            nextTimeout.tv_sec = form->lastTimeout.tv_sec + 
                    (form->timer / 1000);
            nextTimeout.tv_usec = form->lastTimeout.tv_usec + 
                                    (form->timer % 1000) * 1000;
 
-           gettimeofday(&now, 0);
-
            if (now.tv_sec > nextTimeout.tv_sec) {
                timeout.tv_sec = timeout.tv_usec = 0;
            } else if (now.tv_sec == nextTimeout.tv_sec) {
index ca10eec04c6b018245c46a4344a42fb5ed3a1410..66280cfb88858d347a5634bde57790672493cc1e 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -88,6 +88,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libnewt.a
 
 %changelog
+- cope with backward system time jumps (#240691)
 - free helplines and windows in newtFinished, check for overflow (#239992)
 - add release to -devel and -static requires (#238784)
 - fix cursor positioning when setting entry or checkbox flags