diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index 77c47fafa..7ce89f234 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -131,6 +131,14 @@ CLCD4l::~CLCD4l() thrLCD4l = NULL; } +CLCD4l *CLCD4l::getInstance() +{ + static CLCD4l *me = NULL; + if (!me) + me = new CLCD4l(); + return me; +} + /* ----------------------------------------------------------------- */ void CLCD4l::InitLCD4l() diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index cb1fb4445..d50fc9b2e 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -38,6 +38,7 @@ class CLCD4l public: CLCD4l(); ~CLCD4l(); + static CLCD4l *getInstance(); // Displays enum diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 45da27d31..5178f8fe8 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -58,7 +58,6 @@ #ifdef ENABLE_LCD4LINUX #include "driver/lcd4l.h" -extern CLCD4l *LCD4l; #endif extern CBouquetManager *g_bouquetManager; @@ -598,7 +597,7 @@ int CBouquetList::show(bool bShowChannelList) cGLCD::unlockChannel(); #endif #ifdef ENABLE_LCD4LINUX - LCD4l->RemoveFile("/tmp/lcd/menu"); + CLCD4l::getInstance()->RemoveFile("/tmp/lcd/menu"); #endif fader.StopFade(); @@ -664,7 +663,7 @@ void CBouquetList::paintItem(int pos) #endif #ifdef ENABLE_LCD4LINUX if(g_settings.lcd4l_support) - LCD4l->CreateFile("/tmp/lcd/menu", lname, g_settings.lcd4l_convert); + CLCD4l::getInstance()->CreateFile("/tmp/lcd/menu", lname, g_settings.lcd4l_convert); #endif } else diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 4f917c6f1..90ecf4e35 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -88,7 +88,6 @@ #ifdef ENABLE_LCD4LINUX #include "driver/lcd4l.h" -extern CLCD4l *LCD4l; #endif extern CBouquetList * bouquetList; /* neutrino.cpp */ @@ -980,7 +979,7 @@ int CChannelList::show() cGLCD::unlockChannel(); #endif #ifdef ENABLE_LCD4LINUX - LCD4l->RemoveFile("/tmp/lcd/menu"); + CLCD4l::getInstance()->RemoveFile("/tmp/lcd/menu"); #endif if(!dont_hide){ @@ -2268,7 +2267,7 @@ void CChannelList::updateVfd() #endif #ifdef ENABLE_LCD4LINUX if (g_settings.lcd4l_support) - LCD4l->CreateFile("/tmp/lcd/menu", chan->getName().c_str(), g_settings.lcd4l_convert); + CLCD4l::getInstance()->CreateFile("/tmp/lcd/menu", chan->getName().c_str(), g_settings.lcd4l_convert); #endif } diff --git a/src/gui/lcd4l_setup.cpp b/src/gui/lcd4l_setup.cpp index bc52e453c..e6b514c71 100644 --- a/src/gui/lcd4l_setup.cpp +++ b/src/gui/lcd4l_setup.cpp @@ -52,7 +52,6 @@ #include #include "driver/lcd4l.h" -extern CLCD4l *LCD4l; const CMenuOptionChooser::keyval LCD4L_SUPPORT_OPTIONS[] = { @@ -146,9 +145,9 @@ bool CLCD4lSetup::changeNotify(const neutrino_locale_t OptionName, void * /*data if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCD4L_SUPPORT)) { - LCD4l->StopLCD4l(); + CLCD4l::getInstance()->StopLCD4l(); if (g_settings.lcd4l_support) - LCD4l->StartLCD4l(); + CLCD4l::getInstance()->StartLCD4l(); } else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCD4L_DISPLAY_TYPE)) { @@ -251,10 +250,10 @@ int CLCD4lSetup::show() } if (initlcd4l) - LCD4l->InitLCD4l(); + CLCD4l::getInstance()->InitLCD4l(); if (g_settings.lcd4l_support == 1 ) // automatic - LCD4l->ForceRun(); + CLCD4l::getInstance()->ForceRun(); return res; } @@ -295,11 +294,11 @@ int CLCD4lSetup::showTypeSetup() mc->setHint(NEUTRINO_ICON_HINT_LCD4LINUX, LOCALE_MENU_HINT_LCD4L_SKIN_RADIO); typeSetup->addItem(mc); - nc = new CMenuOptionNumberChooser(LOCALE_LCD4L_BRIGHTNESS, (int *)&temp_lcd4l_brightness, true, 1, LCD4l->GetMaxBrightness(), this); + nc = new CMenuOptionNumberChooser(LOCALE_LCD4L_BRIGHTNESS, (int *)&temp_lcd4l_brightness, true, 1, CLCD4l::getInstance()->GetMaxBrightness(), this); nc->setHint(NEUTRINO_ICON_HINT_LCD4LINUX, LOCALE_MENU_HINT_LCD4L_BRIGHTNESS); typeSetup->addItem(nc); - nc = new CMenuOptionNumberChooser(LOCALE_LCD4L_BRIGHTNESS_STANDBY, (int *)&g_settings.lcd4l_brightness_standby, !g_settings.shutdown_real, 1, LCD4l->GetMaxBrightness(), this); + nc = new CMenuOptionNumberChooser(LOCALE_LCD4L_BRIGHTNESS_STANDBY, (int *)&g_settings.lcd4l_brightness_standby, !g_settings.shutdown_real, 1, CLCD4l::getInstance()->GetMaxBrightness(), this); nc->setHint(NEUTRINO_ICON_HINT_LCD4LINUX, LOCALE_MENU_HINT_LCD4L_BRIGHTNESS_STANDBY); typeSetup->addItem(nc); diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index eb91fe1a6..5d64fc10b 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -73,7 +73,6 @@ #ifdef ENABLE_LCD4LINUX #include "driver/lcd4l.h" -extern CLCD4l *LCD4l; #endif extern CRemoteControl * g_RemoteControl; @@ -1618,7 +1617,7 @@ bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) #ifdef ENABLE_LCD4LINUX else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_CHANNELLIST_SHOW_EVENTLOGO)) { - LCD4l->ResetParseID(); + CLCD4l::getInstance()->ResetParseID(); } #endif else if ((ARE_LOCALES_EQUAL(OptionName, LOCALE_MISCSETTINGS_INFOCLOCK)) || diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index f2ca42269..8d5cdd670 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -49,7 +49,6 @@ #ifdef ENABLE_LCD4LINUX #include "driver/lcd4l.h" -extern CLCD4l *LCD4l; #endif /* the following generic menu items are integrated into multiple menus at the same time */ @@ -255,7 +254,7 @@ void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text #endif #ifdef ENABLE_LCD4LINUX if (g_settings.lcd4l_support) - LCD4l->CreateFile("/tmp/lcd/menu", lcd_text, g_settings.lcd4l_convert); + CLCD4l::getInstance()->CreateFile("/tmp/lcd/menu", lcd_text, g_settings.lcd4l_convert); #endif } @@ -1030,7 +1029,7 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) cGLCD::unlockChannel(); #endif #ifdef ENABLE_LCD4LINUX - LCD4l->RemoveFile("/tmp/lcd/menu"); + CLCD4l::getInstance()->RemoveFile("/tmp/lcd/menu"); #endif //exec this item... @@ -1052,7 +1051,7 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) #endif #ifdef ENABLE_LCD4LINUX if (g_settings.lcd4l_support) - LCD4l->CreateFile("/tmp/lcd/menu", item->lcd_text, g_settings.lcd4l_convert); + CLCD4l::getInstance()->CreateFile("/tmp/lcd/menu", item->lcd_text, g_settings.lcd4l_convert); #endif switch ( rv ) { @@ -1143,7 +1142,7 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) cGLCD::unlockChannel(); #endif #ifdef ENABLE_LCD4LINUX - LCD4l->RemoveFile("/tmp/lcd/menu"); + CLCD4l::getInstance()->RemoveFile("/tmp/lcd/menu"); #endif for (unsigned int count = 0; count < items.size(); count++) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 78e2ad37e..2254fe72c 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -174,7 +174,6 @@ CInfoIcons *InfoIcons; #ifdef ENABLE_LCD4LINUX #include "driver/lcd4l.h" -CLCD4l *LCD4l; #endif int allow_flash = 1; @@ -3128,11 +3127,8 @@ TIMER_START(); SHTDCNT::getInstance()->init(); #ifdef ENABLE_LCD4LINUX - if (LCD4l == NULL) - LCD4l = new CLCD4l(); - if (g_settings.lcd4l_support) - LCD4l->StartLCD4l(); + CLCD4l::getInstance()->StartLCD4l(); #endif CZapit::getInstance()->SetScanSDT(g_settings.enable_sdt); @@ -5494,13 +5490,8 @@ void CNeutrinoApp::stopDaemonsForFlash() #ifdef ENABLE_LCD4LINUX void stop_lcd4l_support() { - if(LCD4l) { - if(g_settings.lcd4l_support) { - LCD4l->StopLCD4l(); - } - delete LCD4l; - } - LCD4l = NULL; + if (g_settings.lcd4l_support) + CLCD4l::getInstance()->StopLCD4l(); } #endif diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 79427fe85..768fc0fbd 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -46,7 +46,6 @@ #ifdef ENABLE_LCD4LINUX #include "driver/lcd4l.h" -extern CLCD4l *LCD4l; #endif CFlashTool::CFlashTool() @@ -353,7 +352,7 @@ void CFlashTool::stopDaemons() { #ifdef ENABLE_LCD4LINUX if (g_settings.lcd4l_support) - LCD4l->StopLCD4l(); + CLCD4l::getInstance()->StopLCD4l(); #endif CNeutrinoApp::getInstance()->stopDaemonsForFlash();