Make the beginResetModel/mList.clear()/endResetModel sequence atomic in Event Log and Chat lists

delete event log list to avoid core residual leading to SafeConnections not destroyed
This commit is contained in:
Gaelle Braud 2026-02-24 09:26:27 +01:00
parent adb6c34124
commit 5e3668fdeb
5 changed files with 24 additions and 17 deletions

View file

@ -102,8 +102,6 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
return;
}
setIsUpdating(true);
beginResetModel();
mList.clear();
mModelConnection->invokeToModel([this]() {
mustBeInLinphoneThread(getClassName());
// Avoid copy to lambdas
@ -111,8 +109,10 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
if (!currentAccount) {
mModelConnection->invokeToCore([this, chats]() {
setIsUpdating(false);
beginResetModel();
mList.clear();
endResetModel();
setIsUpdating(false);
});
return;
}
@ -123,6 +123,8 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
}
mModelConnection->invokeToCore([this, chats]() {
mustBeInMainThread(getClassName());
beginResetModel();
mList.clear();
for (auto &chat : getSharedList<ChatCore>()) {
if (chat) {
disconnectItem(chat);

View file

@ -309,12 +309,12 @@ void EventLogList::setSelf(QSharedPointer<EventLogList> me) {
return;
}
setIsUpdating(true);
beginResetModel();
for (auto &event : getSharedList<EventLogCore>()) {
disconnectItem(event);
}
mList.clear();
if (!mChatCore) {
beginResetModel();
mList.clear();
endResetModel();
setIsUpdating(false);
emit modelUpdated();
@ -322,6 +322,8 @@ void EventLogList::setSelf(QSharedPointer<EventLogList> me) {
}
auto chatModel = mChatCore->getModel();
if (!chatModel) {
beginResetModel();
mList.clear();
endResetModel();
setIsUpdating(false);
emit modelUpdated();
@ -336,10 +338,13 @@ void EventLogList::setSelf(QSharedPointer<EventLogList> me) {
if (it->getChatMessage() || model->isHandled()) events->push_front(model);
}
mCoreModelConnection->invokeToCore([this, events] {
beginResetModel();
mList.clear();
for (auto &event : *events) {
connectItem(event);
mList.append(event);
}
delete events;
endResetModel();
setIsUpdating(false);
emit modelUpdated();

View file

@ -2086,13 +2086,13 @@
<context>
<name>ChatDroppableTextArea</name>
<message>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="164"/>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="163"/>
<source>chat_view_send_area_placeholder_text</source>
<extracomment>Say something : placeholder text for sending message text area</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="203"/>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="202"/>
<source>cannot_record_while_in_call_tooltip</source>
<extracomment>Cannot record a message while a call is ongoing</extracomment>
<translation type="unfinished"></translation>
@ -2769,13 +2769,13 @@ Error</extracomment>
<context>
<name>ConferenceInfoCore</name>
<message>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="585"/>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="587"/>
<source>information_popup_error_title</source>
<extracomment>&quot;Erreur&quot;</extracomment>
<translation>Fehler</translation>
</message>
<message>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="587"/>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="589"/>
<source>information_popup_disconnected_account_message</source>
<extracomment>&quot;Votre compte est déconnecté&quot;</extracomment>
<translation>Ihr Konto ist getrennt</translation>

View file

@ -2079,13 +2079,13 @@
<context>
<name>ChatDroppableTextArea</name>
<message>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="164"/>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="163"/>
<source>chat_view_send_area_placeholder_text</source>
<extracomment>Say something : placeholder text for sending message text area</extracomment>
<translation>Say something</translation>
</message>
<message>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="203"/>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="202"/>
<source>cannot_record_while_in_call_tooltip</source>
<extracomment>Cannot record a message while a call is ongoing</extracomment>
<translation>Cannot record a message while a call is ongoing</translation>
@ -2754,13 +2754,13 @@ Only your correspondent can decrypt them.</translation>
<context>
<name>ConferenceInfoCore</name>
<message>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="585"/>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="587"/>
<source>information_popup_error_title</source>
<extracomment>&quot;Erreur&quot;</extracomment>
<translation>Error</translation>
</message>
<message>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="587"/>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="589"/>
<source>information_popup_disconnected_account_message</source>
<extracomment>&quot;Votre compte est déconnecté&quot;</extracomment>
<translation>Your account is disconnected</translation>

View file

@ -2054,13 +2054,13 @@
<context>
<name>ChatDroppableTextArea</name>
<message>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="164"/>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="163"/>
<source>chat_view_send_area_placeholder_text</source>
<extracomment>Say something : placeholder text for sending message text area</extracomment>
<translation>Dites quelque chose</translation>
</message>
<message>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="203"/>
<location filename="../../view/Control/Input/Chat/ChatDroppableTextArea.qml" line="202"/>
<source>cannot_record_while_in_call_tooltip</source>
<extracomment>Cannot record a message while a call is ongoing</extracomment>
<translation>Impossible d&apos;enregistrer un message vocal pendant un appel</translation>
@ -2729,13 +2729,13 @@ en bout. Seul votre correspondant peut les déchiffrer.</translation>
<context>
<name>ConferenceInfoCore</name>
<message>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="585"/>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="587"/>
<source>information_popup_error_title</source>
<extracomment>&quot;Erreur&quot;</extracomment>
<translation>Erreur</translation>
</message>
<message>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="587"/>
<location filename="../../core/conference/ConferenceInfoCore.cpp" line="589"/>
<source>information_popup_disconnected_account_message</source>
<extracomment>&quot;Votre compte est déconnecté&quot;</extracomment>
<translation>Votre compte est déconnecté</translation>