Fix critical crashes:

- set cpp managment for list
- remove items stored in shared pointer that are managed by Gui
- queue connection for signals between GUI/Core in order to avoid calling functions while destructions.
This commit is contained in:
Julien Wadel 2024-10-02 09:55:03 +02:00
parent b9417f5a72
commit 975c461a4d
13 changed files with 52 additions and 38 deletions

View file

@ -77,9 +77,12 @@ void AccountProxy::setSourceModel(QAbstractItemModel *model) {
}
auto newAccountList = dynamic_cast<AccountList *>(model);
if (newAccountList) {
connect(newAccountList, &AccountList::countChanged, this, &AccountProxy::resetDefaultAccount);
connect(newAccountList, &AccountList::defaultAccountChanged, this, &AccountProxy::resetDefaultAccount);
connect(newAccountList, &AccountList::haveAccountChanged, this, &AccountProxy::haveAccountChanged);
connect(newAccountList, &AccountList::countChanged, this, &AccountProxy::resetDefaultAccount,
Qt::QueuedConnection);
connect(newAccountList, &AccountList::defaultAccountChanged, this, &AccountProxy::resetDefaultAccount,
Qt::QueuedConnection);
connect(newAccountList, &AccountList::haveAccountChanged, this, &AccountProxy::haveAccountChanged,
Qt::QueuedConnection);
}
QSortFilterProxyModel::setSourceModel(model);
}

View file

@ -43,6 +43,7 @@ QSharedPointer<LdapCore> LdapList::createLdapCore(const std::shared_ptr<linphone
LdapList::LdapList(QObject *parent) : ListProxy(parent) {
mustBeInMainThread(getClassName());
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
}
LdapList::~LdapList() {

View file

@ -44,6 +44,7 @@ CallHistoryList::createCallHistoryCore(const std::shared_ptr<linphone::CallLog>
CallHistoryList::CallHistoryList(QObject *parent) : ListProxy(parent) {
mustBeInMainThread(getClassName());
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
}
CallHistoryList::~CallHistoryList() {

View file

@ -72,8 +72,8 @@ void CallProxy::setSourceModel(QAbstractItemModel *model) {
}
auto newCallList = dynamic_cast<CallList *>(model);
if (newCallList) {
connect(newCallList, &CallList::currentCallChanged, this, &CallProxy::resetCurrentCall);
connect(newCallList, &CallList::haveCallChanged, this, &CallProxy::haveCallChanged);
connect(newCallList, &CallList::currentCallChanged, this, &CallProxy::resetCurrentCall, Qt::QueuedConnection);
connect(newCallList, &CallList::haveCallChanged, this, &CallProxy::haveCallChanged, Qt::QueuedConnection);
connect(this, &CallProxy::lMergeAll, newCallList, &CallList::lMergeAll);
}
QSortFilterProxyModel::setSourceModel(model);

View file

@ -40,6 +40,7 @@ QSharedPointer<ConferenceInfoList> ConferenceInfoList::create() {
ConferenceInfoList::ConferenceInfoList(QObject *parent) : ListProxy(parent) {
mustBeInMainThread(getClassName());
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
}
ConferenceInfoList::~ConferenceInfoList() {

View file

@ -28,18 +28,24 @@ DEFINE_ABSTRACT_OBJECT(ConferenceInfoProxy)
ConferenceInfoProxy::ConferenceInfoProxy(QObject *parent) : SortFilterProxy(parent) {
mList = ConferenceInfoList::create();
setSourceModel(mList.get());
connect(this, &ConferenceInfoProxy::searchTextChanged, [this] {
invalidate();
updateCurrentDateIndex();
});
connect(mList.get(), &ConferenceInfoList::haveCurrentDateChanged, [this] {
invalidate();
updateCurrentDateIndex();
});
connect(
this, &ConferenceInfoProxy::searchTextChanged, this,
[this] {
invalidate();
updateCurrentDateIndex();
},
Qt::QueuedConnection);
connect(
mList.get(), &ConferenceInfoList::haveCurrentDateChanged, this,
[this] {
invalidate();
updateCurrentDateIndex();
},
Qt::QueuedConnection);
connect(mList.get(), &ConferenceInfoList::haveCurrentDateChanged, this,
&ConferenceInfoProxy::haveCurrentDateChanged);
&ConferenceInfoProxy::haveCurrentDateChanged, Qt::QueuedConnection);
connect(mList.get(), &ConferenceInfoList::currentDateIndexChanged, this,
&ConferenceInfoProxy::updateCurrentDateIndex);
&ConferenceInfoProxy::updateCurrentDateIndex, Qt::QueuedConnection);
}
ConferenceInfoProxy::~ConferenceInfoProxy() {
@ -96,4 +102,4 @@ bool ConferenceInfoProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sou
return !mList->haveCurrentDate() && mList->getCount() > 1 &&
mSearchText.isEmpty(); // if mlist count == 1 there is only the dummy row which we don't display alone
}
}
}

View file

@ -43,14 +43,6 @@ void FriendInitialProxy::setFilterText(const QString &filter) {
}
}
// void FriendInitialProxy::setSourceModel(QAbstractItemModel *sourceModel) {
// mSource = qSharedPointerCast<MagicSearchProxy>(QSharedPointer<QAbstractItemModel>(sourceModel));
// }
// QAbstractItemModel *FriendInitialProxy::sourceModel() const {
// return mSource.get();
// }
bool FriendInitialProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
bool show = (mFilterText.isEmpty() || mFilterText == "*");
if (!show) {

View file

@ -53,8 +53,6 @@ protected:
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
QString mFilterText;
QSharedPointer<MagicSearchProxy> mSource;
DECLARE_ABSTRACT_OBJECT
};

View file

@ -32,7 +32,8 @@ DEFINE_GUI_OBJECT(ParticipantDeviceProxy)
ParticipantDeviceProxy::ParticipantDeviceProxy(QObject *parent) : SortFilterProxy(parent) {
mParticipants = ParticipantDeviceList::create();
connect(mParticipants.get(), &ParticipantDeviceList::countChanged, this, &ParticipantDeviceProxy::meChanged);
connect(mParticipants.get(), &ParticipantDeviceList::countChanged, this, &ParticipantDeviceProxy::meChanged,
Qt::QueuedConnection);
setSourceModel(mParticipants.get());
sort(0); //, Qt::DescendingOrder);

View file

@ -36,6 +36,7 @@ QSharedPointer<PhoneNumberList> PhoneNumberList::create() {
PhoneNumberList::PhoneNumberList(QObject *parent) : ListProxy(parent) {
mustBeInMainThread(getClassName());
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
App::postModelAsync([=]() {
// Model thread.
auto dialPlans = linphone::Factory::get()->getDialPlans();

View file

@ -39,6 +39,7 @@ QSharedPointer<MagicSearchList> MagicSearchList::create() {
MagicSearchList::MagicSearchList(QObject *parent) : ListProxy(parent) {
mustBeInMainThread(getClassName());
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
mSourceFlags = (int)linphone::MagicSearch::Source::Friends | (int)linphone::MagicSearch::Source::LdapServers;
mAggregationFlag = LinphoneEnums::MagicSearchAggregation::Friend;
mSearchFilter = "*";

View file

@ -43,17 +43,25 @@ void MagicSearchProxy::setList(QSharedPointer<MagicSearchList> newList) {
}
mList = newList;
if (mList) {
connect(mList.get(), &MagicSearchList::sourceFlagsChanged, this, &MagicSearchProxy::sourceFlagsChanged);
connect(mList.get(), &MagicSearchList::aggregationFlagChanged, this, &MagicSearchProxy::aggregationFlagChanged);
connect(mList.get(), &MagicSearchList::friendCreated, this, [this](int index) {
auto proxyIndex = mapFromSource(sourceModel()->index(index, 0));
emit friendCreated(proxyIndex.row());
});
connect(mList.get(), &MagicSearchList::initialized, this, [this, newList = mList.get()] {
emit newList->lSetSourceFlags(mSourceFlags);
emit newList->lSetAggregationFlag(mAggregationFlag);
emit initialized();
});
connect(mList.get(), &MagicSearchList::sourceFlagsChanged, this, &MagicSearchProxy::sourceFlagsChanged,
Qt::QueuedConnection);
connect(mList.get(), &MagicSearchList::aggregationFlagChanged, this, &MagicSearchProxy::aggregationFlagChanged,
Qt::QueuedConnection);
connect(
mList.get(), &MagicSearchList::friendCreated, this,
[this](int index) {
auto proxyIndex = mapFromSource(sourceModel()->index(index, 0));
emit friendCreated(proxyIndex.row());
},
Qt::QueuedConnection);
connect(
mList.get(), &MagicSearchList::initialized, this,
[this, newList = mList.get()] {
emit newList->lSetSourceFlags(mSourceFlags);
emit newList->lSetAggregationFlag(mAggregationFlag);
emit initialized();
},
Qt::QueuedConnection);
}
setSourceModel(mList.get());
}

View file

@ -36,6 +36,7 @@ QSharedPointer<TimeZoneList> TimeZoneList::create() {
}
TimeZoneList::TimeZoneList(QObject *parent) : ListProxy(parent) {
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
initTimeZones();
}