Filter DataItems with suitable way.

We should carefully modify unordered_set when traversing it.
Update the iterator with the return value of erase function.

Change-Id: I777f42b077502f617a513128db9a4f3b7c9a322c
CRs-Fixed: 2288358
This commit is contained in:
Baili Feng 2018-08-15 20:54:54 +08:00
parent 329de0d44f
commit de454e21f6

View file

@ -328,9 +328,12 @@ void SystemStatusOsObserver::notify(const list<IDataItemCore*>& dlist)
for (auto client : clientSet) {
unordered_set<DataItemId> dataItemIdsForThisClient(
mParent->mClientToDataItems.getValSet(client));
for (auto id : dataItemIdsForThisClient) {
if (dataItemIdsToBeSent.find(id) == dataItemIdsToBeSent.end()) {
dataItemIdsForThisClient.erase(id);
for (auto itr = dataItemIdsForThisClient.begin();
itr != dataItemIdsForThisClient.end(); ) {
if (dataItemIdsToBeSent.find(*itr) == dataItemIdsToBeSent.end()) {
itr = dataItemIdsForThisClient.erase(itr);
} else {
itr++;
}
}