From 1c39a6edf40cd6a3bd4d3fde5678df42e3eff80b Mon Sep 17 00:00:00 2001 From: martii Date: Tue, 8 Apr 2014 21:19:51 +0200 Subject: [PATCH] [experimental] gui/components/cc_frm_clock: use a mutex around unsetting/evaluating paintClock. This may or may not help with the clock-still-showing-when-leaving-the-channellist problem. Pretty much untested, as that issue is quite irreproducible. --- src/gui/components/cc_frm_clock.cpp | 24 ++++++++---------------- src/gui/components/cc_frm_clock.h | 6 ++++++ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 5f06b78b4..465ba8f2a 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -260,24 +260,14 @@ void* CComponentsFrmClock::initClockThread(void *arg) pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0); CComponentsFrmClock *clock = static_cast(arg); -#if 0 - time_t count = time(0); -#endif //start loop for paint - while(clock != NULL) { - if (clock->paintClock) { + while (true) { + clock->mutex.lock(); + if (clock->paintClock) clock->paint(CC_SAVE_SCREEN_NO); -#if 0 - count = time(0); -#endif - } -#if 0 // memory leak, thread will not be joined --martii - if (time(0) >= count+30) { - clock->cl_thread = 0; - break; - } -#endif - mySleep(clock->cl_interval); + clock->mutex.unlock(); + int interval = clock->cl_interval; + mySleep(interval); } return 0; } @@ -336,7 +326,9 @@ bool CComponentsFrmClock::Stop() { if (!activeClock) return false; + mutex.lock(); paintClock = false; + mutex.unlock(); return cl_thread == 0 ? false : true; } diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index ede5d9002..09a0ea987 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -31,6 +31,10 @@ #include #endif +#include +#include +#include + #include "cc_base.h" #include "cc_frm.h" @@ -90,6 +94,8 @@ class CComponentsFrmClock : public CComponentsForm inline Font** getClockFont(); public: + OpenThreads::Mutex mutex; + CComponentsFrmClock( const int& x_pos = 1, const int& y_pos = 1, const int& w = 200, const int& h = 48, const char* format_str = "%H:%M", bool activ=false,