diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index 45c522814..3e5539769 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 6894e9786..1929c9814 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -39,6 +39,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 b18d4868e..48478f087 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){ @@ -2265,7 +2264,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 2adc3292c..660849966 100644 --- a/src/gui/lcd4l_setup.cpp +++ b/src/gui/lcd4l_setup.cpp @@ -53,7 +53,6 @@ #include #include "driver/lcd4l.h" -extern CLCD4l *LCD4l; const CMenuOptionChooser::keyval LCD4L_SUPPORT_OPTIONS[] = { @@ -144,9 +143,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)) { @@ -248,10 +247,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; } @@ -283,11 +282,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 5c9c64c00..91c94fdb2 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; @@ -1585,7 +1584,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 70f2e841a..593660276 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 76e2e095f..af4b93080 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -170,7 +170,6 @@ CTimeOSD *FileTimeOSD; #ifdef ENABLE_LCD4LINUX #include "driver/lcd4l.h" -CLCD4l *LCD4l = NULL; #endif int allow_flash = 1; @@ -3007,11 +3006,7 @@ TIMER_START(); CVFD::getInstance()->setMuted(current_muted); #ifdef ENABLE_LCD4LINUX - if (g_settings.lcd4l_support) { - if (LCD4l == NULL) - LCD4l = new CLCD4l(); - LCD4l->StartLCD4l(); - } + CLCD4l::getInstance()->StartLCD4l(); #endif #ifdef ENABLE_GRAPHLCD @@ -3063,11 +3058,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); @@ -5354,13 +5346,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 c6b5b9e2b..c13bc451b 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() @@ -346,7 +345,7 @@ void CFlashTool::stopDaemons() { #ifdef ENABLE_LCD4LINUX if (g_settings.lcd4l_support) - LCD4l->StopLCD4l(); + CLCD4l::getInstance()->StopLCD4l(); #endif CNeutrinoApp::getInstance()->stopDaemonsForFlash();