From 0e91dae9223a0b82085e28c42483122681106100 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Thu, 25 Jan 2018 14:34:15 +0200 Subject: [PATCH] Erase items using the key --- include/CommunitiesList.h | 2 +- src/AvatarProvider.cc | 2 +- src/ChatPage.cc | 5 +++-- src/CommunitiesList.cc | 6 ------ src/RoomList.cc | 2 +- src/RoomState.cc | 2 +- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/CommunitiesList.h b/include/CommunitiesList.h index 8bb6aaad..d03d32a2 100644 --- a/include/CommunitiesList.h +++ b/include/CommunitiesList.h @@ -20,7 +20,7 @@ public: void clear() { communities_.clear(); } void addCommunity(QSharedPointer community, const QString &id); - void removeCommunity(const QString &id); + void removeCommunity(const QString &id) { communities_.erase(id); }; signals: void communityChanged(const QString &id); diff --git a/src/AvatarProvider.cc b/src/AvatarProvider.cc index f39d9870..1cdf03ac 100644 --- a/src/AvatarProvider.cc +++ b/src/AvatarProvider.cc @@ -39,7 +39,7 @@ AvatarProvider::updateAvatar(const QString &uid, const QImage &img) for (const auto callback : callbacks) callback(img); - toBeResolved_.erase(toBeResolved_.find(uid)); + toBeResolved_.erase(uid); } auto avatarData = avatars_[uid]; diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 6d9c87f2..d1a76f83 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -761,8 +761,9 @@ ChatPage::addRoom(const QString &room_id) void ChatPage::removeRoom(const QString &room_id) { - roomStates_.erase(roomStates_.find(room_id)); - roomSettings_.erase(roomSettings_.find(room_id)); + roomStates_.erase(room_id); + roomSettings_.erase(room_id); + try { cache_->removeRoom(room_id); cache_->removeInvite(room_id); diff --git a/src/CommunitiesList.cc b/src/CommunitiesList.cc index 1469dd87..2814a6b3 100644 --- a/src/CommunitiesList.cc +++ b/src/CommunitiesList.cc @@ -100,12 +100,6 @@ CommunitiesList::addCommunity(QSharedPointer community, const QString &CommunitiesList::highlightSelectedCommunity); } -void -CommunitiesList::removeCommunity(const QString &community_id) -{ - communities_.erase(communities_.find(community_id)); -} - void CommunitiesList::updateCommunityAvatar(const QString &community_id, const QPixmap &img) { diff --git a/src/RoomList.cc b/src/RoomList.cc index fefd8dac..8d4cf30b 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc @@ -123,7 +123,7 @@ RoomList::updateAvatar(const QString &room_id, const QString &url) void RoomList::removeRoom(const QString &room_id, bool reset) { - rooms_.erase(rooms_.find(room_id)); + rooms_.erase(room_id); if (rooms_.empty() || !reset) return; diff --git a/src/RoomState.cc b/src/RoomState.cc index 2bfea173..afd887ad 100644 --- a/src/RoomState.cc +++ b/src/RoomState.cc @@ -157,7 +157,7 @@ RoomState::update(const RoomState &state) } if (membershipState == mtx::events::state::Membership::Leave) - this->memberships.erase(this->memberships.find(it->first)); + this->memberships.erase(it->first); else this->memberships.emplace(it->first, it->second); }