Commit bc0de770 authored by Ronan's avatar Ronan Committed by Ronan

fix(CoreManager): replace assert by log if chat model id is invalid in...

fix(CoreManager): replace assert by log if chat model id is invalid in getChatModel (avoid crash for specific migrated chat rooms)
parent 0b3fd4be
......@@ -121,8 +121,14 @@ shared_ptr<ChatModel> CoreManager::getChatModel (const QString &peerAddress, con
// Create a new chat model.
QPair<QString, QString> chatModelId{ peerAddress, localAddress };
if (!mChatModels.contains(chatModelId)) {
Q_ASSERT(mCore->createAddress(Utils::appStringToCoreString(peerAddress)));
Q_ASSERT(mCore->createAddress(Utils::appStringToCoreString(localAddress)));
if (
!mCore->createAddress(Utils::appStringToCoreString(peerAddress)) ||
!mCore->createAddress(Utils::appStringToCoreString(localAddress))
) {
qWarning() << QStringLiteral("Unable to get chat model from invalid chat model id: (%1, %2).")
.arg(peerAddress).arg(localAddress);
return nullptr;
}
auto deleter = [this, chatModelId](ChatModel *chatModel) {
bool removed = mChatModels.remove(chatModelId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment