Do not leak the sort proxy model

This commit is contained in:
Cătălin Răceanu
2019-02-25 00:00:39 +02:00
parent cb74819562
commit c6354696d4

View File

@@ -20,6 +20,8 @@ namespace
class LexicalSortProxyModel : public QSortFilterProxyModel class LexicalSortProxyModel : public QSortFilterProxyModel
{ {
public: public:
LexicalSortProxyModel(QObject* owner) : QSortFilterProxyModel(owner) {}
bool lessThan( const QModelIndex &left, const QModelIndex &right ) const wxOVERRIDE bool lessThan( const QModelIndex &left, const QModelIndex &right ) const wxOVERRIDE
{ {
const QVariant leftData = sourceModel()->data( left ); const QVariant leftData = sourceModel()->data( left );
@@ -77,7 +79,7 @@ wxChoice::wxChoice() :
void wxChoice::QtInitSort( QComboBox *combo ) void wxChoice::QtInitSort( QComboBox *combo )
{ {
QSortFilterProxyModel *proxyModel = new LexicalSortProxyModel(); QSortFilterProxyModel *proxyModel = new LexicalSortProxyModel(combo);
proxyModel->setSourceModel(combo->model()); proxyModel->setSourceModel(combo->model());
combo->model()->setParent(proxyModel); combo->model()->setParent(proxyModel);
combo->setModel(proxyModel); combo->setModel(proxyModel);