Probable fix of bug #84117 ("date jumps forward when system clock is
author Jason Harris
()
committer Jason Harris
()
commit a82d6a681ed5427ef3d24db7978536a4b50b8747
tree a0936f0b29a6916ebbf7cba3f41c08f4f2b3f2ce
parent 1975185d9a339ad3847252c4a3bad0dfa6058118
Probable fix of bug #84117 ("date jumps forward when system clock is
set back").

KStars keeps time by counting the elapsed milliseconds since an
arbitrary moment in the system time called "sysmark". This is matched
by a corresponding marker for the simulation clock called "julianmark",
which was the exact simulation time at the moment that the system time
was sysmark.

So, at any moment, the simulation time is simply
"julianmark + scale * elapsed", where "scale" is the clock scale (1.0
for real-time), and elapsed is the elapsed time since sysmark according
to the system clock. Because the elapsed time is stored as a QTime, it
cannot record time for more than 24 hours (after that long, it resets to
0 hours). We had accounted for this by advancing the date by one
day when we detected that the elapsed time since sysmark had shrunk,
because the only situation we'd thought of where this would occur, is
when the elapsed time wrapped back to 0 after 24 hours.

The bug reporter found another situation where the elapsed time can
shrink (i.e., if the unix clock is set back while KStars is running).
So, we now simply reset sysmark and julianmark whenever the elapsed time
has shrunk. This properly accounts for both situations.

You may see a slight "hiccup" in the time box when reseting the time,
but it immediately recovers.

Thanks very much for noticing and reporting this subtle bug!

CCMAIL: 84117-done@bugs.kde.org
CCMAIL: kstars-devel@kde.org

svn path=/trunk/kdeedu/kstars/; revision=324187
kstars/ksnewstuff.cpp
kstars/ksnewstuff.h
kstars/simclock.cpp