moved calls to setDynamicSortFilter(false) into constructors of sort proxy models

This commit is contained in:
csoler 2021-02-02 12:37:15 +01:00
parent 95e1073b8a
commit d4141c493d
5 changed files with 21 additions and 14 deletions

View File

@ -99,6 +99,12 @@ public:
SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent) SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
{ {
m_dirModel = dirModel; m_dirModel = dirModel;
// Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot
// deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either.
//Ghibli: set false because by default in qt5 is true and makes rs crash when sorting, all this decided by Cyril not me :D it works
setDynamicSortFilter(false);
} }
protected: protected:
@ -193,12 +199,6 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent)
flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
// Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot
// deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either.
//Ghibli: set false because by default in qt5 is true and makes rs crash when sorting, all this decided by Cyril not me :D it works
tree_proxyModel->setDynamicSortFilter(false);
flat_proxyModel->setDynamicSortFilter(false);
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter())); connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));

View File

@ -111,7 +111,10 @@ public:
: QSortFilterProxyModel(parent) : QSortFilterProxyModel(parent)
, m_header(header) , m_header(header)
, m_sortingEnabled(false), m_sortByState(false) , m_sortingEnabled(false), m_sortByState(false)
, m_showOfflineNodes(true) {} , m_showOfflineNodes(true)
{
setDynamicSortFilter(false); // causes crashes when true.
}
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
{ {
@ -184,7 +187,6 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
mProxyModel->setSourceModel(mModel); mProxyModel->setSourceModel(mModel);
mProxyModel->setSortRole(RsFriendListModel::SortRole); mProxyModel->setSortRole(RsFriendListModel::SortRole);
mProxyModel->setDynamicSortFilter(false);
mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
mProxyModel->setFilterRole(RsFriendListModel::FilterRole); mProxyModel->setFilterRole(RsFriendListModel::FilterRole);
mProxyModel->setFilterRegExp(QRegExp(RsFriendListModel::FilterString)); mProxyModel->setFilterRegExp(QRegExp(RsFriendListModel::FilterString));

View File

@ -64,7 +64,9 @@ class FSMSortFilterProxyModel : public QSortFilterProxyModel
{ {
public: public:
FSMSortFilterProxyModel( QObject *parent) : QSortFilterProxyModel(parent) FSMSortFilterProxyModel( QObject *parent) : QSortFilterProxyModel(parent)
{} {
setDynamicSortFilter(false); // essential to avoid random crashes
}
protected: protected:
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
@ -201,7 +203,6 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName
connect(_dirModel, SIGNAL(directoryLoaded(QString)), this, SLOT(directoryLoaded(QString))); connect(_dirModel, SIGNAL(directoryLoaded(QString)), this, SLOT(directoryLoaded(QString)));
_tree_proxyModel = new FSMSortFilterProxyModel(this); _tree_proxyModel = new FSMSortFilterProxyModel(this);
_tree_proxyModel->setDynamicSortFilter(true);
_tree_proxyModel->setSourceModel(_dirModel); _tree_proxyModel->setSourceModel(_dirModel);
_tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); _tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
_tree_proxyModel->setSortRole(Qt::DisplayRole); _tree_proxyModel->setSortRole(Qt::DisplayRole);

View File

@ -206,7 +206,10 @@ public:
class ForumPostSortFilterProxyModel: public QSortFilterProxyModel class ForumPostSortFilterProxyModel: public QSortFilterProxyModel
{ {
public: public:
explicit ForumPostSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),m_header(header) {} explicit ForumPostSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),m_header(header)
{
setDynamicSortFilter(false); // causes crashes when true
}
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
{ {
@ -257,7 +260,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
mThreadModel = new RsGxsForumModel(this); mThreadModel = new RsGxsForumModel(this);
mThreadProxyModel = new ForumPostSortFilterProxyModel(ui->threadTreeWidget->header(),this); mThreadProxyModel = new ForumPostSortFilterProxyModel(ui->threadTreeWidget->header(),this);
mThreadProxyModel->setSourceModel(mThreadModel); mThreadProxyModel->setSourceModel(mThreadModel);
mThreadProxyModel->setDynamicSortFilter(false); // causes crashes when true.
mThreadProxyModel->setSortRole(RsGxsForumModel::SortRole); mThreadProxyModel->setSortRole(RsGxsForumModel::SortRole);
ui->threadTreeWidget->setModel(mThreadProxyModel); ui->threadTreeWidget->setModel(mThreadProxyModel);

View File

@ -98,7 +98,10 @@
class MessageSortFilterProxyModel: public QSortFilterProxyModel class MessageSortFilterProxyModel: public QSortFilterProxyModel
{ {
public: public:
MessageSortFilterProxyModel(QObject *parent = NULL): QSortFilterProxyModel(parent), m_sortingEnabled(false) {} MessageSortFilterProxyModel(QObject *parent = NULL): QSortFilterProxyModel(parent), m_sortingEnabled(false)
{
setDynamicSortFilter(false); // causes crashes when true
}
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
{ {
@ -145,7 +148,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
mMessageProxyModel = new MessageSortFilterProxyModel(this); mMessageProxyModel = new MessageSortFilterProxyModel(this);
mMessageProxyModel->setSourceModel(mMessageModel); mMessageProxyModel->setSourceModel(mMessageModel);
mMessageProxyModel->setSortRole(RsMessageModel::SortRole); mMessageProxyModel->setSortRole(RsMessageModel::SortRole);
mMessageProxyModel->setDynamicSortFilter(false);
mMessageProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); mMessageProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole); mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole);
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString));