From 53c83d3585fdca5cc00940adb0f21f9e83bf53e6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 31 Oct 2017 17:34:13 +0100 Subject: [PATCH] Fixed ChatRoom state changed with Created state before RAM insertion breaking find --- coreapi/callbacks.c | 1 + coreapi/chat.c | 2 ++ src/chat/chat-room/client-group-chat-room.cpp | 1 + src/core/core-chat-room.cpp | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 7930e3029..9897bea60 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -799,6 +799,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ } else { LinphoneChatRoom *cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->join(); + L_GET_PRIVATE(lc->cppCore)->insertChatRoom(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::Created); L_GET_PRIVATE(lc->cppCore)->insertChatRoomWithDb(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); static_cast(op)->reply(SalReasonNone); diff --git a/coreapi/chat.c b/coreapi/chat.c index ba45d60b2..352c01cd8 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -82,12 +82,14 @@ LinphoneChatRoom *linphone_core_create_client_group_chat_room (LinphoneCore *lc, LinphoneChatRoom *_linphone_core_join_client_group_chat_room (LinphoneCore *lc, const LinphonePrivate::Address &addr) { LinphoneChatRoom *cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->join(); + L_GET_PRIVATE(lc->cppCore)->insertChatRoom(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); L_GET_PRIVATE(lc->cppCore)->insertChatRoomWithDb(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); return cr; } LinphoneChatRoom *_linphone_core_create_server_group_chat_room (LinphoneCore *lc, LinphonePrivate::SalCallOp *op) { LinphoneChatRoom *cr = _linphone_server_group_chat_room_new(lc, op); + L_GET_PRIVATE(lc->cppCore)->insertChatRoom(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); L_GET_PRIVATE(lc->cppCore)->insertChatRoomWithDb(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); return cr; } diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 45a412023..e47f34fba 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -254,6 +254,7 @@ void ClientGroupChatRoom::onConferenceCreated (const Address &addr) { L_D_T(RemoteConference, dConference); dConference->conferenceAddress = addr; d->peerAddress = addr; + d->core->cppCore->getPrivate()->insertChatRoom(getSharedFromThis()); d->setState(ChatRoom::State::Created); d->core->cppCore->getPrivate()->insertChatRoomWithDb(getSharedFromThis()); } diff --git a/src/core/core-chat-room.cpp b/src/core/core-chat-room.cpp index 5cbe89f40..3e8e668c9 100644 --- a/src/core/core-chat-room.cpp +++ b/src/core/core-chat-room.cpp @@ -66,6 +66,7 @@ shared_ptr CorePrivate::createChatRoom (const Address &peerAddress, bo chatRoom = ObjectFactory::create(cCore, peerAddress); ChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); + insertChatRoom(chatRoom); dChatRoom->setState(ChatRoom::State::Instantiated); dChatRoom->setState(ChatRoom::State::Created); @@ -74,7 +75,6 @@ shared_ptr CorePrivate::createChatRoom (const Address &peerAddress, bo void CorePrivate::insertChatRoom (const shared_ptr &chatRoom) { L_ASSERT(chatRoom); - L_ASSERT(chatRoom->getState() == ChatRoom::State::Created); Address cleanedPeerAddress = getCleanedPeerAddress(chatRoom->getPeerAddress()); @@ -104,7 +104,7 @@ void CorePrivate::deleteChatRoom (const string &peerAddress) { } void CorePrivate::insertChatRoomWithDb (const shared_ptr &chatRoom) { - insertChatRoom(chatRoom); + L_ASSERT(chatRoom->getState() == ChatRoom::State::Created); ChatRoom::CapabilitiesMask capabilities = chatRoom->getCapabilities(); mainDb->insertChatRoom(