From 1b5e00e705ba332403f451c3aa425a952e5fd3fd Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 20 Feb 2018 12:05:59 +0100 Subject: [PATCH] Fix assert when inserting a chat room in DB. --- src/core/core-chat-room.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/core-chat-room.cpp b/src/core/core-chat-room.cpp index 745a3944d..e9bc24996 100644 --- a/src/core/core-chat-room.cpp +++ b/src/core/core-chat-room.cpp @@ -106,9 +106,13 @@ shared_ptr CorePrivate::createClientGroupChatRoom (const strin void CorePrivate::insertChatRoom (const shared_ptr &chatRoom) { L_ASSERT(chatRoom); - L_ASSERT(!chatRoomsById[chatRoom->getChatRoomId()]); - chatRooms.push_back(chatRoom); - chatRoomsById[chatRoom->getChatRoomId()] = chatRoom; + L_ASSERT(!chatRoomsById[chatRoom->getChatRoomId()] + || (chatRoomsById[chatRoom->getChatRoomId()] == chatRoom) + ); + if (!chatRoomsById[chatRoom->getChatRoomId()]) { + chatRooms.push_back(chatRoom); + chatRoomsById[chatRoom->getChatRoomId()] = chatRoom; + } } void CorePrivate::insertChatRoomWithDb (const shared_ptr &chatRoom) {