Skip to content

Commit

Permalink
Merge branch 'hotfix/v4.12.0c' into 'release/v4.12.0'
Browse files Browse the repository at this point in the history
CHT-936. Fix openchatroom (hotfix for v4.12.0)

See merge request megachat/MEGAchat!1641
  • Loading branch information
mattw-mega committed Jun 22, 2023
2 parents 493626d + 6e3cc55 commit 5e051ca
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/megachatapi_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4995,16 +4995,23 @@ bool MegaChatApiImpl::openChatRoom(MegaChatHandle chatid, MegaChatRoomListener *
return false;
}

sdkMutex.lock();

SdkMutexGuard g(sdkMutex);
ChatRoom* chatroom = findChatRoom(chatid);
if (!chatroom || !chatroom->setAppChatHandler(getChatRoomHandler(chatid)))
if (!chatroom)
{
API_LOG_WARNING("openChatRoom. chatroom not found. chatid: %s"
, karere::Id(chatid).toString().c_str());
return false;
}

if (chatroom->appChatHandler())
{
API_LOG_WARNING("App chat handler is already set, remove it first. chatid: %s"
, karere::Id(chatid).toString().c_str());
return false;
}
addChatRoomListener(chatid, listener);
sdkMutex.unlock();
chatroom->setAppChatHandler(getChatRoomHandler(chatid));
return chatroom;
}

Expand Down

0 comments on commit 5e051ca

Please sign in to comment.