mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-02-01 03:19:23 +00:00
Fix participant devices leaks.
This commit is contained in:
parent
c870daf530
commit
53abdf6f06
9 changed files with 50 additions and 7 deletions
|
|
@ -35,6 +35,19 @@ ProxyModel::ProxyModel (QAbstractItemModel * model, const int& defaultFilterMode
|
|||
sort(0, Qt::DescendingOrder);
|
||||
}
|
||||
|
||||
ProxyModel::~ProxyModel(){
|
||||
if(mDeleteSourceModel)
|
||||
deleteSourceModel();
|
||||
}
|
||||
|
||||
void ProxyModel::deleteSourceModel(){
|
||||
auto oldSourceModel = sourceModel();
|
||||
if(oldSourceModel) {
|
||||
oldSourceModel->deleteLater();
|
||||
setSourceModel(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int ProxyModel::getFilterMode () const {
|
||||
return mFilterMode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ public:
|
|||
|
||||
ProxyModel (QObject *parent = Q_NULLPTR);
|
||||
ProxyModel (QAbstractItemModel * list, const int& defaultFilterMode, QObject *parent = Q_NULLPTR);
|
||||
virtual ~ProxyModel();
|
||||
|
||||
virtual void deleteSourceModel();
|
||||
|
||||
int getFilterMode () const;
|
||||
void setFilterMode (int filterMode);
|
||||
|
|
@ -56,6 +59,8 @@ protected:
|
|||
bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
|
||||
|
||||
bool mDeleteSourceModel = false;
|
||||
|
||||
private:
|
||||
int mFilterMode;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,6 +26,19 @@ SortFilterProxyModel::SortFilterProxyModel(QObject * parent) : QSortFilterProxyM
|
|||
connect(this, &SortFilterProxyModel::rowsRemoved, this, &SortFilterProxyModel::countChanged);
|
||||
}
|
||||
|
||||
SortFilterProxyModel::~SortFilterProxyModel(){
|
||||
if(mDeleteSourceModel)
|
||||
deleteSourceModel();
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::deleteSourceModel(){
|
||||
auto oldSourceModel = sourceModel();
|
||||
if(oldSourceModel) {
|
||||
oldSourceModel->deleteLater();
|
||||
setSourceModel(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int SortFilterProxyModel::getCount() const{
|
||||
return rowCount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ public:
|
|||
Q_PROPERTY(int filterType READ getFilterType WRITE setFilterType NOTIFY filterTypeChanged)
|
||||
|
||||
SortFilterProxyModel(QObject * parent = nullptr);
|
||||
virtual ~SortFilterProxyModel();
|
||||
virtual void deleteSourceModel();
|
||||
|
||||
virtual int getCount() const;
|
||||
virtual int getFilterType () const;
|
||||
|
|
@ -47,6 +49,7 @@ signals:
|
|||
|
||||
protected:
|
||||
int mFilterType;
|
||||
bool mDeleteSourceModel = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ ChatRoomProxyModel::ChatRoomProxyModel (QObject *parent) : QSortFilterProxyModel
|
|||
}
|
||||
|
||||
ChatRoomProxyModel::~ChatRoomProxyModel(){
|
||||
setSourceModel(nullptr);
|
||||
setChatRoomModel(nullptr); // Do remove process like setting haveCall if is Call.
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
using namespace std;
|
||||
|
||||
ConferenceProxyModel::ConferenceProxyModel (QObject *parent) : SortFilterProxyModel(parent) {
|
||||
mDeleteSourceModel = false;
|
||||
setSourceModel(CoreManager::getInstance()->getCallsListModel());
|
||||
emit conferenceChanged();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
TimeZoneProxyModel::TimeZoneProxyModel (QObject *parent) : SortFilterProxyModel(parent) {
|
||||
mDeleteSourceModel = true;
|
||||
setSourceModel(new TimeZoneListModel(parent));
|
||||
sort(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@
|
|||
// =============================================================================
|
||||
|
||||
ParticipantDeviceProxyModel::ParticipantDeviceProxyModel (QObject *parent) : SortFilterProxyModel(parent){
|
||||
mDeleteSourceModel = true;
|
||||
}
|
||||
|
||||
ParticipantDeviceProxyModel::~ParticipantDeviceProxyModel(){
|
||||
}
|
||||
|
||||
bool ParticipantDeviceProxyModel::filterAcceptsRow (
|
||||
|
|
@ -85,18 +89,20 @@ void ParticipantDeviceProxyModel::connectTo(ParticipantDeviceListModel* model){
|
|||
void ParticipantDeviceProxyModel::setCallModel(CallModel * callModel){
|
||||
setFilterType(1);
|
||||
mCallModel = callModel;
|
||||
auto sourceModel = new ParticipantDeviceListModel(mCallModel);
|
||||
connectTo(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
deleteSourceModel();
|
||||
auto newSourceModel = new ParticipantDeviceListModel(mCallModel);
|
||||
connectTo(newSourceModel);
|
||||
setSourceModel(newSourceModel);
|
||||
emit countChanged();
|
||||
emit meChanged();
|
||||
}
|
||||
|
||||
void ParticipantDeviceProxyModel::setParticipant(ParticipantModel * participant){
|
||||
setFilterType(0);
|
||||
auto sourceModel = participant->getParticipantDevices().get();
|
||||
connectTo(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
deleteSourceModel();
|
||||
auto newSourceModel = participant->getParticipantDevices().get();
|
||||
connectTo(newSourceModel);
|
||||
setSourceModel(newSourceModel);
|
||||
emit countChanged();
|
||||
emit meChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public:
|
|||
Q_PROPERTY(ParticipantDeviceModel* activeSpeaker READ getActiveSpeakerModel NOTIFY activeSpeakerChanged)
|
||||
|
||||
ParticipantDeviceProxyModel (QObject *parent = nullptr);
|
||||
~ParticipantDeviceProxyModel();
|
||||
|
||||
Q_INVOKABLE ParticipantDeviceModel* getAt(int row);
|
||||
ParticipantDeviceModel* getActiveSpeakerModel();
|
||||
|
|
@ -76,7 +77,6 @@ protected:
|
|||
virtual bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
virtual bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
|
||||
|
||||
QSharedPointer<ParticipantDeviceListModel> mDevices;
|
||||
CallModel * mCallModel;
|
||||
bool mShowMe = true;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue