mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
Make the beginResetModel/mList.clear()/endResetModel sequence atomic
Delete raw pointer lists after items are added to the lists
This commit is contained in:
parent
e2c0f622e6
commit
d6df08168d
3 changed files with 17 additions and 5 deletions
|
|
@ -51,14 +51,17 @@ void ChatMessageFileList::setSelf(QSharedPointer<ChatMessageFileList> me) {
|
|||
mCoreModelConnection = SafeConnection<ChatMessageFileList, CoreModel>::create(me, CoreModel::getInstance());
|
||||
mCoreModelConnection->makeConnectToCore(&ChatMessageFileList::lUpdate, [this]() {
|
||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
|
||||
if (!mChat) {
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
endResetModel();
|
||||
return;
|
||||
}
|
||||
auto chatModel = mChat->getModel();
|
||||
if (!chatModel) {
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
endResetModel();
|
||||
return;
|
||||
}
|
||||
|
|
@ -87,9 +90,12 @@ void ChatMessageFileList::setSelf(QSharedPointer<ChatMessageFileList> me) {
|
|||
contents->push_back(model);
|
||||
}
|
||||
mCoreModelConnection->invokeToCore([this, contents] {
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
for (auto i : *contents)
|
||||
mList << i.template objectCast<QObject>();
|
||||
endResetModel();
|
||||
delete contents;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ void EventLogList::displayMore() {
|
|||
}
|
||||
add(*events);
|
||||
}
|
||||
delete events;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
@ -201,6 +202,7 @@ void EventLogList::loadMessagesUpTo(std::shared_ptr<linphone::EventLog> event) {
|
|||
connectItem(e);
|
||||
}
|
||||
add(*events);
|
||||
delete events;
|
||||
emit messagesLoadedUpTo(event);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,12 +71,11 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
|
|||
setIsUpdating(true);
|
||||
mCoreModelConnection->invokeToModel([this]() {
|
||||
mustBeInLinphoneThread(getClassName());
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
QList<QSharedPointer<ConferenceInfoCore>> *items = new QList<QSharedPointer<ConferenceInfoCore>>();
|
||||
auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
||||
setAccountConnected(defaultAccount && defaultAccount->getState() == linphone::RegistrationState::Ok);
|
||||
if (!defaultAccount || !mAccountConnected) {
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
endResetModel();
|
||||
setIsUpdating(false);
|
||||
return;
|
||||
|
|
@ -84,10 +83,13 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
|
|||
std::list<std::shared_ptr<linphone::ConferenceInfo>> conferenceInfos =
|
||||
defaultAccount->getConferenceInformationList();
|
||||
if (conferenceInfos.empty()) {
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
endResetModel();
|
||||
setIsUpdating(false);
|
||||
return;
|
||||
}
|
||||
QList<QSharedPointer<ConferenceInfoCore>> *items = new QList<QSharedPointer<ConferenceInfoCore>>();
|
||||
items->push_back(nullptr); // Add Dummy conference for today
|
||||
for (auto conferenceInfo : conferenceInfos) {
|
||||
// if (conferenceInfo->getState() == linphone::ConferenceInfo::State::Cancelled) {
|
||||
|
|
@ -102,6 +104,8 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
|
|||
}
|
||||
mCoreModelConnection->invokeToCore([this, items]() {
|
||||
mustBeInMainThread(getClassName());
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
for (auto &item : *items) {
|
||||
connectItem(item);
|
||||
mList << item.template objectCast<QObject>();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue