-fix memleak hdd menu

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1020 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
satbaby
2011-01-08 19:39:05 +00:00
parent dfaf4ff485
commit 0283037fac

View File

@@ -114,6 +114,7 @@ int CHDDMenuHandler::doMenu ()
root_dev = (s.st_dev & 0x0ffc0); /* hda = 0x0300, hdb = 0x0340 */ root_dev = (s.st_dev & 0x0ffc0); /* hda = 0x0300, hdb = 0x0340 */
printf("HDD: root_dev: 0x%04x\n", root_dev); printf("HDD: root_dev: 0x%04x\n", root_dev);
std::string tmp_str[n]; std::string tmp_str[n];
CMenuWidget * tempMenu[n];
for(int i = 0; i < n;i++) { for(int i = 0; i < n;i++) {
char str[256]; char str[256];
char sstr[256]; char sstr[256];
@@ -174,14 +175,14 @@ int CHDDMenuHandler::doMenu ()
snprintf(str, sizeof(str), "%s %s %lld %s", vendor, model, megabytes < 10000 ? megabytes : megabytes/1000, megabytes < 10000 ? "MB" : "GB"); snprintf(str, sizeof(str), "%s %s %lld %s", vendor, model, megabytes < 10000 ? megabytes : megabytes/1000, megabytes < 10000 ? "MB" : "GB");
printf("HDD: %s\n", str); printf("HDD: %s\n", str);
tmp_str[i]=str; tmp_str[i]=str;
CMenuWidget * tempMenu = new CMenuWidget(str, NEUTRINO_ICON_SETTINGS); tempMenu[i] = new CMenuWidget(str, NEUTRINO_ICON_SETTINGS);
tempMenu->addIntroItems(); tempMenu[i]->addIntroItems();
//tempMenu->addItem( new CMenuOptionChooser(LOCALE_HDD_FS, &g_settings.hdd_fs, HDD_FILESYS_OPTIONS, HDD_FILESYS_OPTION_COUNT, true)); //tempMenu->addItem( new CMenuOptionChooser(LOCALE_HDD_FS, &g_settings.hdd_fs, HDD_FILESYS_OPTIONS, HDD_FILESYS_OPTION_COUNT, true));
tempMenu->addItem(new CMenuForwarder(LOCALE_HDD_FORMAT, true, "", new CHDDFmtExec, namelist[i]->d_name)); tempMenu[i]->addItem(new CMenuForwarder(LOCALE_HDD_FORMAT, true, "", new CHDDFmtExec, namelist[i]->d_name));
tempMenu->addItem(new CMenuForwarder(LOCALE_HDD_CHECK, true, "", new CHDDChkExec, namelist[i]->d_name)); tempMenu[i]->addItem(new CMenuForwarder(LOCALE_HDD_CHECK, true, "", new CHDDChkExec, namelist[i]->d_name));
snprintf(sstr, sizeof(sstr), "%s (%s)", g_Locale->getText(LOCALE_HDD_REMOVABLE_DEVICE), namelist[i]->d_name); snprintf(sstr, sizeof(sstr), "%s (%s)", g_Locale->getText(LOCALE_HDD_REMOVABLE_DEVICE), namelist[i]->d_name);
hddmenu->addItem(new CMenuForwarderNonLocalized((removable ? sstr : namelist[i]->d_name), (removable || isroot) ? false : true, tmp_str[i], tempMenu)); hddmenu->addItem(new CMenuForwarderNonLocalized((removable ? sstr : namelist[i]->d_name), (removable || isroot) ? false : true, tmp_str[i], tempMenu[i]));
hdd_found = 1; hdd_found = 1;
free(namelist[i]); free(namelist[i]);
@@ -193,6 +194,12 @@ int CHDDMenuHandler::doMenu ()
hddmenu->addItem(new CMenuForwarder(LOCALE_HDD_NOT_FOUND, false)); hddmenu->addItem(new CMenuForwarder(LOCALE_HDD_NOT_FOUND, false));
ret = hddmenu->exec(NULL, ""); ret = hddmenu->exec(NULL, "");
for(int i = 0; i < n;i++) {
if( hdd_found && tempMenu[i] != NULL ){
delete tempMenu[i];
}
}
delete hddmenu; delete hddmenu;
return ret; return ret;
} }