1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-30 21:01:07 +03:00
Commit Graph

4 Commits

Author SHA1 Message Date
Maarten ter Huurne
9e1f717d9b Made Clock destruction safe
SDL does not guard against the final callback still executing when the
call to remove the timer returns. So we have to make sure the object
we access on the callback is not prematurely destructed. This commit
uses shared_ptr and weak_ptr to ensure that.

Note that we sort-of have a singleton again, only now it is private
and safely destructed.
2013-08-09 03:13:02 +02:00
Maarten ter Huurne
9158b90a45 Made Clock simpler and more reliable
Removed the suspend check: the best thing we can do after oversleeping
is the same as when we're woken right on time: fetch the time and
reschedule for the next minute boundary.

Don't create a new timer on every callback; instead return the next
interval to SDL.
2013-08-07 03:08:48 +02:00
Maarten ter Huurne
a15339d425 Cleanups of Clock class
Don't make Clock a singleton. While there should be no reason to
instantiate this class more than once, there is no problem with doing
that either. Removing the singleton makes it easier to control access
to the instance. It also avoids the rather nasty construct that was
used to delete it.

Make sure the timer callback function is a proper C function, since
SDL is a C library. This requires some trickery to be able to call
a private method from the callback, but I found a way using an
intermediate nested class. The compiler should be able to inline this
to eliminate any overhead.

Also some minor cleanups.
2013-08-07 02:55:23 +02:00
Paul Cercueil
47bbc0b673 Added a clock on the bottom bar 2013-07-21 23:54:09 -04:00