From 5c635ab5c266a782f1e3000ea1650ac270e935bc Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 23 Jan 2018 17:35:27 +0100 Subject: [PATCH] fix(core-chat-room): add a workaround to deal with destroyed chat rooms --- src/core/core-chat-room.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/core-chat-room.cpp b/src/core/core-chat-room.cpp index 599513e4a..9c9eb07f3 100644 --- a/src/core/core-chat-room.cpp +++ b/src/core/core-chat-room.cpp @@ -254,8 +254,18 @@ void Core::deleteChatRoom (const shared_ptr &chatRoom) { const ChatRoomId &chatRoomId = chatRoom->getChatRoomId(); auto it = d->chatRoomsById.find(chatRoomId); if (it != d->chatRoomsById.end()) { - auto it = find(d->chatRooms.begin(), d->chatRooms.end(), chatRoom); - L_ASSERT(it != d->chatRooms.end()); + + // TODO: Remove me later. + auto it = find_if( + d->chatRooms.begin(), d->chatRooms.end(), + [&chatRoomId](const shared_ptr &chatRoom) { + return chatRoom->getChatRoomId() == chatRoomId; + } + ); + + // FIXME: Use this code in the future. (Wait for signals.) + // auto it = find(d->chatRooms.begin(), d->chatRooms.end(), chatRoom); + // L_ASSERT(it != d->chatRooms.end()); d->chatRooms.erase(it); d->mainDb->deleteChatRoom(chatRoomId); }