diff --git a/Linphone/core/chat/ChatCore.cpp b/Linphone/core/chat/ChatCore.cpp index d128e1b3..6acd8dec 100644 --- a/Linphone/core/chat/ChatCore.cpp +++ b/Linphone/core/chat/ChatCore.cpp @@ -43,7 +43,7 @@ QSharedPointer ChatCore::create(const std::shared_ptr &chatRoom) : QObject(nullptr) { - // lDebug() << "[ChatCore] new" << this; + lDebug() << "[ChatCore] new" << this; mustBeInLinphoneThread(getClassName()); App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership); mLastUpdatedTime = QDateTime::fromSecsSinceEpoch(chatRoom->getLastUpdateTime()); @@ -211,7 +211,7 @@ void ChatCore::setSelf(QSharedPointer me) { const std::shared_ptr &eventLog) { if (mChatModel->getMonitor() != chatRoom) return; if (!eventLog) return; - lDebug() << "EVENT LOG RECEIVED IN CHATROOM" << mChatModel->getTitle(); + lDebug() << log().arg("EVENT LOG RECEIVED IN CHATROOM") << this << mChatModel->getTitle(); auto event = EventLogCore::create(eventLog, chatRoom); if (event->isHandled()) { mChatModelConnection->invokeToCore([this, event]() { emit eventsInserted({event}); }); @@ -224,7 +224,7 @@ void ChatCore::setSelf(QSharedPointer me) { &ChatModel::chatMessagesReceived, [this](const std::shared_ptr &chatRoom, const std::list> &eventsLog) { if (mChatModel->getMonitor() != chatRoom) return; - lDebug() << "CHAT MESSAGE RECEIVED IN CHATROOM" << mChatModel->getTitle(); + lDebug() << log().arg("CHAT MESSAGE RECEIVED IN CHATROOM") << this << mChatModel->getTitle(); QList> list; for (auto &e : eventsLog) { auto event = EventLogCore::create(e, chatRoom); diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 65808e84..1a012932 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -130,6 +130,7 @@ void ChatList::setSelf(QSharedPointer me) { } endResetModel(); setIsUpdating(false); + chats->clear(); delete chats; }); }); diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index 489f473e..261d008b 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -1592,7 +1592,7 @@ VariantObject *Utils::getCurrentCallChat(CallGui *call) { auto linphoneChatRoom = ToolModel::lookupCurrentCallChat(callModel); if (linphoneChatRoom) { auto chatCore = ChatCore::create(linphoneChatRoom); - return QVariant::fromValue(new ChatGui(chatCore)); + return chatCore ? QVariant::fromValue(new ChatGui(chatCore)) : QVariant(); } else { // Only try to create chatroom if 1-1 call if (!callModel->getConference()) { @@ -1603,7 +1603,7 @@ VariantObject *Utils::getCurrentCallChat(CallGui *call) { lInfo() << "[Utils] Chatroom created with" << callModel->getRemoteAddress()->asStringUriOnly(); auto id = linphoneChatRoom->getIdentifier(); auto chatCore = ChatCore::create(linphoneChatRoom); - return QVariant::fromValue(new ChatGui(chatCore)); + return chatCore ? QVariant::fromValue(new ChatGui(chatCore)) : QVariant(); } else { lWarning() << "[Utils] Failed to create 1-1 conversation with" << callModel->getRemoteAddress()->asStringUriOnly() << "!"; @@ -1625,14 +1625,14 @@ VariantObject *Utils::getChatForAddress(QString address) { auto linphoneChatRoom = ToolModel::lookupChatForAddress(linAddr); if (linphoneChatRoom) { auto chatCore = ChatCore::create(linphoneChatRoom); - return QVariant::fromValue(new ChatGui(chatCore)); + return chatCore ? QVariant::fromValue(new ChatGui(chatCore)) : QVariant(); } else { lInfo() << "[Utils] Did not find existing chat room, create one"; linphoneChatRoom = ToolModel::createChatForAddress(linAddr); if (linphoneChatRoom != nullptr) { lInfo() << "[Utils] Chatroom created with" << linAddr->asStringUriOnly(); auto chatCore = ChatCore::create(linphoneChatRoom); - return QVariant::fromValue(new ChatGui(chatCore)); + return chatCore ? QVariant::fromValue(new ChatGui(chatCore)) : QVariant(); } else { lWarning() << "[Utils] Failed to create 1-1 conversation with" << linAddr->asStringUriOnly() << "!"; //: Failed to create 1-1 conversation with %1 ! @@ -1662,7 +1662,7 @@ VariantObject *Utils::createGroupChat(QString subject, QStringList participantAd auto linphoneChatRoom = ToolModel::createGroupChatRoom(subject, addresses); if (linphoneChatRoom) { auto chatCore = ChatCore::create(linphoneChatRoom); - return QVariant::fromValue(new ChatGui(chatCore)); + return chatCore ? QVariant::fromValue(new ChatGui(chatCore)) : QVariant(); } else { return QVariant(); } diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index 60b7bd21..1151cb0d 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -60,7 +60,7 @@ ListView { } } onChatAdded: (chat) => { - mainItem.chatToSelect = chat + // mainItem.chatToSelect = chat } onRowsRemoved: { var index = mainItem.currentIndex