diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2013-01-15 20:40:33 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2013-01-15 20:40:33 (GMT) |
commit | 33161595f482d0dad950ce127b6016eefe8ea691 (patch) | |
tree | 27fa5588b2ddd7410eb083d7bf0c8811d72f8270 /src/FbTk/Timer.hh | |
parent | 239e895826b2f843bc50cc6fef8108db174c33e8 (diff) | |
download | fluxbox-33161595f482d0dad950ce127b6016eefe8ea691.zip fluxbox-33161595f482d0dad950ce127b6016eefe8ea691.tar.bz2 |
Simplifies and fix bugs in FbTk::Timer
* Calling Timer::setTimeout() from within Timer::start() might lead to ugly
behavior (as experienced in bugs #3590078, #3600143, etc; see commit
4d307dcd10af9d817ff5c05fc40ae7487564cb31, fixes the problem partially).
* Stop a timer first, then call the handler (via Timer::fireTimeout()). A
given handler might call Timer::start() again, which (re)adds the Timer
to the control list .. the following Timer::stop() would remove it again.
* Use 'm_start' as indicator if timer is running.
* Move the (now quite short) code of ::addTimer / ::removeTimer
into the Timer::start() and Timer::stop() functions.
Diffstat (limited to 'src/FbTk/Timer.hh')
-rw-r--r-- | src/FbTk/Timer.hh | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/FbTk/Timer.hh b/src/FbTk/Timer.hh index bdaf3b8..2e82f2a 100644 --- a/src/FbTk/Timer.hh +++ b/src/FbTk/Timer.hh | |||
@@ -61,7 +61,7 @@ public: | |||
61 | 61 | ||
62 | static void updateTimers(int file_descriptor); | 62 | static void updateTimers(int file_descriptor); |
63 | 63 | ||
64 | int isTiming() const { return m_timing; } | 64 | int isTiming() const { return (m_start > 0); } |
65 | int getInterval() const { return m_interval; } | 65 | int getInterval() const { return m_interval; } |
66 | 66 | ||
67 | int doOnce() const { return m_once; } | 67 | int doOnce() const { return m_once; } |
@@ -77,11 +77,10 @@ protected: | |||
77 | private: | 77 | private: |
78 | RefCount<Slot<void> > m_handler; ///< what to do on a timeout | 78 | RefCount<Slot<void> > m_handler; ///< what to do on a timeout |
79 | 79 | ||
80 | bool m_timing; ///< clock running? | ||
81 | bool m_once; ///< do timeout only once? | 80 | bool m_once; ///< do timeout only once? |
82 | int m_interval; ///< Is an interval-only timer (e.g. clock), in seconds | 81 | int m_interval; ///< Is an interval-only timer (e.g. clock), in seconds |
83 | 82 | ||
84 | uint64_t m_start; ///< start time in microseconds | 83 | uint64_t m_start; ///< start time in microseconds, 0 if not running |
85 | uint64_t m_timeout; ///< time length in microseconds | 84 | uint64_t m_timeout; ///< time length in microseconds |
86 | }; | 85 | }; |
87 | 86 | ||