NetworkStatus: do not show non-present interfaces
Used explicit type declaration instead of auto and old style map erase() function to (hopefully) make it compatible with gcc2 builds. Change-Id: I8314665a3a3468f11bcac11367ee69d9a3ed2a05 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5380 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
9c4a46b318
commit
702ff4212d
@ -519,9 +519,11 @@ NetworkStatusView::_Update(bool force)
|
||||
BNetworkRoster& roster = BNetworkRoster::Default();
|
||||
BNetworkInterface interface;
|
||||
uint32 cookie = 0;
|
||||
std::set<BString> currentInterfaces;
|
||||
|
||||
while (roster.GetNextInterface(&cookie, interface) == B_OK) {
|
||||
if ((interface.Flags() & IFF_LOOPBACK) == 0) {
|
||||
currentInterfaces.insert((BString)interface.Name());
|
||||
int32 oldStatus = kStatusUnknown;
|
||||
if (fInterfaceStatuses.find(interface.Name())
|
||||
!= fInterfaceStatuses.end()) {
|
||||
@ -550,6 +552,17 @@ NetworkStatusView::_Update(bool force)
|
||||
fInterfaceStatuses[interface.Name()] = status;
|
||||
}
|
||||
}
|
||||
|
||||
// Check every element in fInterfaceStatuses against our current interface
|
||||
// list. If it's not there, then the interface is not present anymore and
|
||||
// should be removed from fInterfaceStatuses.
|
||||
std::map<BString, int32>::iterator it = fInterfaceStatuses.begin();
|
||||
while (it != fInterfaceStatuses.end()) {
|
||||
std::map<BString, int32>::iterator backupIt = it;
|
||||
if (currentInterfaces.find(it->first) == currentInterfaces.end())
|
||||
fInterfaceStatuses.erase(it);
|
||||
it = ++backupIt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user