miscsettings.cpp: fix some memleaks and CPU-Menu segfault

Origin commit data
------------------
Branch: ni/coolstream
Commit: 86a415f0b4
Author: GetAway <get-away@t-online.de>
Date: 2021-03-31 (Wed, 31 Mar 2021)

Origin message was:
------------------
- miscsettings.cpp: fix some memleaks and CPU-Menu segfault

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
GetAway
2021-03-31 22:15:28 +02:00
committed by vanhofen
parent 2a52ae3ef6
commit 14fa711bd1
2 changed files with 12 additions and 3 deletions

View File

@@ -69,6 +69,10 @@ CMiscMenue::CMiscMenue()
{ {
width = 50; width = 50;
fanNotifier = NULL;
cpuNotifier = NULL;
sectionsdConfigNotifier = NULL;
epg_save = NULL; epg_save = NULL;
epg_save_standby = NULL; epg_save_standby = NULL;
epg_save_frequently = NULL; epg_save_frequently = NULL;
@@ -76,6 +80,7 @@ CMiscMenue::CMiscMenue()
epg_read_now = NULL; epg_read_now = NULL;
epg_read_frequently = NULL; epg_read_frequently = NULL;
epg_dir = NULL; epg_dir = NULL;
epg_read_now = NULL;
} }
CMiscMenue::~CMiscMenue() CMiscMenue::~CMiscMenue()
@@ -262,7 +267,6 @@ int CMiscMenue::showMiscSettingsMenu()
int shortcut = 1; int shortcut = 1;
//misc settings //misc settings
fanNotifier = new CFanControlNotifier();
sectionsdConfigNotifier = new CSectionsdConfigNotifier(); sectionsdConfigNotifier = new CSectionsdConfigNotifier();
CMenuWidget misc_menue(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP); CMenuWidget misc_menue(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP);
@@ -333,9 +337,11 @@ int CMiscMenue::showMiscSettingsMenu()
misc_menue.addItem(mf); misc_menue.addItem(mf);
//CPU //CPU
CMenuWidget misc_menue_cpu(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width);
if (g_info.hw_caps->can_cpufreq) if (g_info.hw_caps->can_cpufreq)
{ {
CMenuWidget misc_menue_cpu(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width); if (cpuNotifier != NULL)
cpuNotifier = new CCpuFreqNotifier();
showMiscSettingsMenuCPUFreq(&misc_menue_cpu); showMiscSettingsMenuCPUFreq(&misc_menue_cpu);
mf = new CMenuForwarder(LOCALE_MISCSETTINGS_CPU, true, NULL, &misc_menue_cpu, NULL, CRCInput::convertDigitToKey(shortcut++)); mf = new CMenuForwarder(LOCALE_MISCSETTINGS_CPU, true, NULL, &misc_menue_cpu, NULL, CRCInput::convertDigitToKey(shortcut++));
mf->setHint("", LOCALE_MENU_HINT_MISC_CPUFREQ); mf->setHint("", LOCALE_MENU_HINT_MISC_CPUFREQ);
@@ -357,6 +363,7 @@ int CMiscMenue::showMiscSettingsMenu()
delete fanNotifier; delete fanNotifier;
delete sectionsdConfigNotifier; delete sectionsdConfigNotifier;
delete cpuNotifier;
return res; return res;
} }
@@ -384,6 +391,8 @@ void CMiscMenue::showMiscSettingsMenuGeneral(CMenuWidget *ms_general)
//fan speed //fan speed
if (g_info.hw_caps->has_fan) if (g_info.hw_caps->has_fan)
{ {
if (fanNotifier != NULL)
fanNotifier = new CFanControlNotifier();
CMenuOptionNumberChooser * mn = new CMenuOptionNumberChooser(LOCALE_FAN_SPEED, &g_settings.fan_speed, true, 1, 14, fanNotifier, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF); CMenuOptionNumberChooser * mn = new CMenuOptionNumberChooser(LOCALE_FAN_SPEED, &g_settings.fan_speed, true, 1, 14, fanNotifier, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF);
mn->setHint("", LOCALE_MENU_HINT_FAN_SPEED); mn->setHint("", LOCALE_MENU_HINT_FAN_SPEED);
ms_general->addItem(mn); ms_general->addItem(mn);
@@ -779,7 +788,6 @@ void CMiscMenue::showMiscSettingsMenuCPUFreq(CMenuWidget *ms_cpu)
{ {
ms_cpu->addIntroItems(LOCALE_MISCSETTINGS_CPU); ms_cpu->addIntroItems(LOCALE_MISCSETTINGS_CPU);
CCpuFreqNotifier * cpuNotifier = new CCpuFreqNotifier();
ms_cpu->addItem(new CMenuOptionChooser(LOCALE_CPU_FREQ_NORMAL, &g_settings.cpufreq, CPU_FREQ_OPTIONS, CPU_FREQ_OPTION_COUNT, true, cpuNotifier)); ms_cpu->addItem(new CMenuOptionChooser(LOCALE_CPU_FREQ_NORMAL, &g_settings.cpufreq, CPU_FREQ_OPTIONS, CPU_FREQ_OPTION_COUNT, true, cpuNotifier));
ms_cpu->addItem(new CMenuOptionChooser(LOCALE_CPU_FREQ_STANDBY, &g_settings.standby_cpufreq, CPU_FREQ_OPTIONS, CPU_FREQ_OPTION_COUNT, true)); ms_cpu->addItem(new CMenuOptionChooser(LOCALE_CPU_FREQ_STANDBY, &g_settings.standby_cpufreq, CPU_FREQ_OPTIONS, CPU_FREQ_OPTION_COUNT, true));
} }

View File

@@ -41,6 +41,7 @@ class CMiscMenue : public CMenuTarget, CChangeObserver
NORWAY = 1, NORWAY = 1,
}; };
CFanControlNotifier *fanNotifier; CFanControlNotifier *fanNotifier;
CCpuFreqNotifier * cpuNotifier;
CSectionsdConfigNotifier* sectionsdConfigNotifier; CSectionsdConfigNotifier* sectionsdConfigNotifier;
//COnOffNotifier* miscNotifier; //COnOffNotifier* miscNotifier;
CMenuOptionChooser * epg_save; CMenuOptionChooser * epg_save;