[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.

This commit is contained in:
martii
2014-04-08 21:19:51 +02:00
committed by [CST] Focus
parent 13118c1148
commit 1c39a6edf4
2 changed files with 14 additions and 16 deletions

View File

@@ -260,24 +260,14 @@ void* CComponentsFrmClock::initClockThread(void *arg)
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0); pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0);
CComponentsFrmClock *clock = static_cast<CComponentsFrmClock*>(arg); CComponentsFrmClock *clock = static_cast<CComponentsFrmClock*>(arg);
#if 0
time_t count = time(0);
#endif
//start loop for paint //start loop for paint
while(clock != NULL) { while (true) {
if (clock->paintClock) { clock->mutex.lock();
if (clock->paintClock)
clock->paint(CC_SAVE_SCREEN_NO); clock->paint(CC_SAVE_SCREEN_NO);
#if 0 clock->mutex.unlock();
count = time(0); int interval = clock->cl_interval;
#endif mySleep(interval);
}
#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);
} }
return 0; return 0;
} }
@@ -336,7 +326,9 @@ bool CComponentsFrmClock::Stop()
{ {
if (!activeClock) if (!activeClock)
return false; return false;
mutex.lock();
paintClock = false; paintClock = false;
mutex.unlock();
return cl_thread == 0 ? false : true; return cl_thread == 0 ? false : true;
} }

View File

@@ -31,6 +31,10 @@
#include <config.h> #include <config.h>
#endif #endif
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Thread>
#include <OpenThreads/Condition>
#include "cc_base.h" #include "cc_base.h"
#include "cc_frm.h" #include "cc_frm.h"
@@ -90,6 +94,8 @@ class CComponentsFrmClock : public CComponentsForm
inline Font** getClockFont(); inline Font** getClockFont();
public: public:
OpenThreads::Mutex mutex;
CComponentsFrmClock( const int& x_pos = 1, const int& y_pos = 1, const int& w = 200, const int& h = 48, 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", const char* format_str = "%H:%M",
bool activ=false, bool activ=false,