gui/network_setup.cpp: fix crash on settings restore, if no wlan present

This commit is contained in:
[CST] Focus
2014-11-20 14:25:48 +03:00
parent 30c5e7b900
commit 156b515155
2 changed files with 14 additions and 17 deletions

View File

@@ -267,11 +267,11 @@ int CNetworkSetup::showNetworkSetup()
m5->setHint("", LOCALE_MENU_HINT_NET_NAMESERVER); m5->setHint("", LOCALE_MENU_HINT_NET_NAMESERVER);
m8->setHint("", LOCALE_MENU_HINT_NET_HOSTNAME); m8->setHint("", LOCALE_MENU_HINT_NET_HOSTNAME);
dhcpDisable[0] = m1; dhcpDisable.Add(m1);
dhcpDisable[1] = m2; dhcpDisable.Add(m2);
dhcpDisable[2] = m3; dhcpDisable.Add(m3);
dhcpDisable[3] = m4; dhcpDisable.Add(m4);
dhcpDisable[4] = m5; dhcpDisable.Add(m5);
CMenuOptionChooser* o2 = new CMenuOptionChooser(LOCALE_NETWORKMENU_DHCP, &network_dhcp, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this); CMenuOptionChooser* o2 = new CMenuOptionChooser(LOCALE_NETWORKMENU_DHCP, &network_dhcp, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this);
o2->setHint("", LOCALE_MENU_HINT_NET_DHCP); o2->setHint("", LOCALE_MENU_HINT_NET_DHCP);
@@ -312,9 +312,9 @@ int CNetworkSetup::showNetworkSetup()
m10->setHint("", LOCALE_MENU_HINT_NET_PASS); m10->setHint("", LOCALE_MENU_HINT_NET_PASS);
m11->setHint("", LOCALE_MENU_HINT_NET_SSID_SCAN); m11->setHint("", LOCALE_MENU_HINT_NET_SSID_SCAN);
wlanEnable[0] = m9; wlanEnable.Add(m9);
wlanEnable[1] = m10; wlanEnable.Add(m10);
wlanEnable[2] = m11; wlanEnable.Add(m11);
networkSettings->addItem( m11); //ssid scan networkSettings->addItem( m11); //ssid scan
networkSettings->addItem( m9); //ssid networkSettings->addItem( m9); //ssid
@@ -384,6 +384,8 @@ int CNetworkSetup::showNetworkSetup()
break; break;
} }
dhcpDisable.Clear();
wlanEnable.Clear();
delete networkSettings; delete networkSettings;
delete sectionsdConfigNotifier; delete sectionsdConfigNotifier;
return ret; return ret;
@@ -655,15 +657,10 @@ bool CNetworkSetup::changeNotify(const neutrino_locale_t locale, void * Data)
changeNotify(LOCALE_NETWORKMENU_DHCP, &CNetworkConfig::getInstance()->inet_static); changeNotify(LOCALE_NETWORKMENU_DHCP, &CNetworkConfig::getInstance()->inet_static);
int ecnt = sizeof(wlanEnable) / sizeof(CMenuForwarder*); wlanEnable.Activate(CNetworkConfig::getInstance()->wireless);
for(int i = 0; i < ecnt; i++)
wlanEnable[i]->setActive(CNetworkConfig::getInstance()->wireless);
} else if(locale == LOCALE_NETWORKMENU_DHCP) { } else if(locale == LOCALE_NETWORKMENU_DHCP) {
CNetworkConfig::getInstance()->inet_static = (network_dhcp == NETWORK_DHCP_OFF); CNetworkConfig::getInstance()->inet_static = (network_dhcp == NETWORK_DHCP_OFF);
int ecnt = sizeof(dhcpDisable) / sizeof(CMenuForwarder*); dhcpDisable.Activate(CNetworkConfig::getInstance()->inet_static);
for(int i = 0; i < ecnt; i++)
dhcpDisable[i]->setActive(CNetworkConfig::getInstance()->inet_static);
} }
return false; return false;
} }

View File

@@ -74,8 +74,8 @@ class CNetworkSetup : public CMenuTarget, CChangeObserver
std::string old_mac_addr; std::string old_mac_addr;
CMenuForwarder* dhcpDisable[5]; CGenericMenuActivate dhcpDisable;
CMenuForwarder* wlanEnable[3]; CGenericMenuActivate wlanEnable;
CSectionsdConfigNotifier* sectionsdConfigNotifier; CSectionsdConfigNotifier* sectionsdConfigNotifier;