SafeConnection premature destruction in ParticipantDeviceList and ParticipantList (cherry pick from quanta)

This commit is contained in:
Gaelle Braud 2026-03-04 16:21:50 +01:00
parent adbc31da57
commit 7dbe238f17
3 changed files with 15 additions and 11 deletions

View file

@ -95,10 +95,10 @@ void ParticipantDeviceList::setConferenceModel(const std::shared_ptr<ConferenceM
if (mConferenceModel != conferenceModel) {
mConferenceModel = conferenceModel;
lDebug() << log().arg("Set Conference %1").arg((quint64)mConferenceModel.get());
if (mConferenceModelConnection->mCore.lock()) { // Ensure to get myself
auto oldConnect = mConferenceModelConnection->mCore; // Setself rebuild safepointer
setSelf(mConferenceModelConnection->mCore.mQData); // reset connections
oldConnect.unlock();
if (mConferenceModelConnection->mCore.lock()) { // Ensure to get myself
auto me = mConferenceModelConnection->mCore.mQData; // Save shared pointer before unlock
mConferenceModelConnection->mCore.unlock(); // Unlock before destroying old connection
setSelf(me); // reset connections
}
beginResetModel();
mList.clear();

View file

@ -105,9 +105,9 @@ void ParticipantList::setConferenceModel(const std::shared_ptr<ConferenceModel>
mConferenceModel = conferenceModel;
lDebug() << "[ParticipantList] : set Conference " << mConferenceModel.get();
if (mConferenceModelConnection && mConferenceModelConnection->mCore.lock()) { // Unsure to get myself
auto oldConnect = mConferenceModelConnection->mCore; // Setself rebuild safepointer
setSelf(mConferenceModelConnection->mCore.mQData); // reset connections
oldConnect.unlock();
auto me = mConferenceModelConnection->mCore.mQData; // Save shared pointer before unlock
mConferenceModelConnection->mCore.unlock(); // Unlock before destroying old connection
setSelf(me); // reset connections
}
beginResetModel();
mList.clear();

View file

@ -74,13 +74,17 @@ protected:
}
~SafeConnection() {
mLocker.lock();
auto coreType = QString(typeid(A).name());
auto modelType = QString(typeid(B).name());
if (mModel.mCountRef != 0)
QTimer::singleShot(1000, mModel.get(), []() {
lCritical() << "[SafeConnection] Destroyed 1s ago but a Model is still in memory";
QTimer::singleShot(1000, mModel.get(), [coreType, modelType]() {
lCritical() << "[SafeConnection] Destroyed 1s ago but a Model is still in memory."
<< "Core:" << coreType << "Model:" << modelType;
});
if (mCore.mCountRef != 0)
QTimer::singleShot(1000, mCore.get(), []() {
lCritical() << "[SafeConnection] Destroyed 1s ago but a Core is still in memory";
QTimer::singleShot(1000, mCore.get(), [coreType, modelType]() {
lCritical() << "[SafeConnection] Destroyed 1s ago but a Core is still in memory."
<< "Core:" << coreType << "Model:" << modelType;
});
mLocker.unlock();
}