From 44d1d8a80804c37a6cadf949fd14863fe2bcc423 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 3 Mar 2013 21:52:21 +0100 Subject: [PATCH] lcdd: add proper destructor to kill time thread --- src/driver/lcdd.cpp | 19 ++++++++++++++++--- src/driver/lcdd.h | 3 +-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/driver/lcdd.cpp b/src/driver/lcdd.cpp index d22b0a73d..e5fe05c92 100644 --- a/src/driver/lcdd.cpp +++ b/src/driver/lcdd.cpp @@ -109,6 +109,17 @@ CLCD::CLCD() */ has_lcd = false; clearClock = 0; + fontRenderer = NULL; + thread_started = false; +} + +CLCD::~CLCD() +{ + if (thread_started) { + thread_started = false; + pthread_join(thrTime, NULL); + } + delete fontRenderer; } CLCD* CLCD::getInstance() @@ -140,9 +151,10 @@ void CLCD::wake_up() { } #ifndef BOXMODEL_DM500 -void* CLCD::TimeThread(void *) +void* CLCD::TimeThread(void *p) { - while(1) + ((CLCD *)p)->thread_started = true; + while (((CLCD *)p)->thread_started) { sleep(1); struct stat buf; @@ -152,6 +164,7 @@ void* CLCD::TimeThread(void *) } else CLCD::getInstance()->wake_up(); } + printf("CLCD::TimeThread exit\n"); return NULL; } #else @@ -202,7 +215,7 @@ void CLCD::init(const char * fontfile, const char * fontname, #endif } - if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) + if (pthread_create (&thrTime, NULL, TimeThread, this) != 0 ) { perror("[lcdd]: pthread_create(TimeThread)"); return ; diff --git a/src/driver/lcdd.h b/src/driver/lcdd.h index 53f71b65b..cb30ae32f 100644 --- a/src/driver/lcdd.h +++ b/src/driver/lcdd.h @@ -150,6 +150,7 @@ class CLCD bool movie_is_ac3; CConfigFile configfile; pthread_t thrTime; + bool thread_started; int last_toggle_state_power; int clearClock; unsigned int timeout_cnt; @@ -235,9 +236,7 @@ class CLCD void Clear(); void ShowIcon(vfd_icon icon, bool show); void ShowText(const char *s) { showServicename(std::string(s), true); }; -#ifndef HAVE_TRIPLEDRAGON ~CLCD(); -#endif #ifdef LCD_UPDATE private: CFileList* m_fileList;