diff --git a/old/services/core/src/subscribemanager/profile_sync_handler.cpp b/old/services/core/src/subscribemanager/profile_sync_handler.cpp index 99f6d943bc8ac59ca928b62bb3fcf26cb1f2e22a..16c76790fc2a1a5c8597979ccc3df5d85bb3bd55 100644 --- a/old/services/core/src/subscribemanager/profile_sync_handler.cpp +++ b/old/services/core/src/subscribemanager/profile_sync_handler.cpp @@ -62,13 +62,16 @@ void ProfileSyncHandler::NotifySyncCompleted(const SyncResult& syncResults) } { std::lock_guard autoLock(notifierLock_); - for (const auto& [notifier, _] : profileEventSubscribeInfos_) { - sptr profileEventNotifier = iface_cast(notifier); + auto iter = profileEventSubscribeInfos_.begin(); + while (iter != profileEventSubscribeInfos_.end()) { + sptr profileEventNotifier = iface_cast(iter->first); if (profileEventNotifier == nullptr) { HILOGE("cast to IProfileEventNotifier failed"); - continue; + iter++; + } else { + profileEventNotifier->OnSyncCompleted(syncResults); + profileEventSubscribeInfos_.erase(iter++); } - profileEventNotifier->OnSyncCompleted(syncResults); } } DeviceProfileStorageManager::GetInstance().NotifySyncCompleted();