on xenial help sign in
properly invalidate the whole model

this fixes a crash in certain circumstances but makes things slower. To compensate the slowness, turning off dynamic sorting/filtering in the topmost proxy models seems to work fine.

commit8394f1e7869314a530b434164d672c84a60e13db authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 25 Jan 2017, 18:44 (10 years ago) parent1a62160
3 files changed+5−6
plugins/Unity/Launcher/appdrawermodel.cpp−4 plugins/Utils/appdrawerproxymodel.cpp+2−2 qml/Launcher/Drawer.qml+3
plugins/Unity/Launcher/appdrawermodel.cpp−4
@@ -43,10 +43,6 @@ int AppDrawerModel::rowCount(const QModelIndex &parent) const
4343
4444QVariant AppDrawerModel::data(const QModelIndex &index, int role) const
4545{
46− if (!index.isValid() || m_list.count() <= index.row()) {
47− return QVariant();
48− }
49−
5046 switch (role) {
5147 case RoleAppId:
5248 return m_list.at(index.row())->appId();
plugins/Utils/appdrawerproxymodel.cpp+2−2
@@ -43,8 +43,8 @@ void AppDrawerProxyModel::setSource(QAbstractItemModel *source)
4343 m_source = source;
4444 setSourceModel(m_source);
4545 setSortRole(m_sortBy == SortByAToZ ? AppDrawerModelInterface::RoleName : AppDrawerModelInterface::RoleUsage);
46− connect(m_source, &QAbstractItemModel::rowsRemoved, this, &AppDrawerProxyModel::invalidateFilter);
47− connect(m_source, &QAbstractItemModel::rowsInserted, this, &AppDrawerProxyModel::invalidateFilter);
46+ connect(m_source, &QAbstractItemModel::rowsRemoved, this, &AppDrawerProxyModel::invalidate);
47+ connect(m_source, &QAbstractItemModel::rowsInserted, this, &AppDrawerProxyModel::invalidate);
4848 Q_EMIT sourceChanged();
4949 }
5050}
qml/Launcher/Drawer.qml+3
@@ -238,6 +238,7 @@ FocusScope {
238238 source: sortProxyModel
239239 group: AppDrawerProxyModel.GroupByAll
240240 sortBy: AppDrawerProxyModel.SortByUsage
241+ dynamicSortFilter: false
241242 }
242243
243244 delegate: UbuntuShape {
@@ -287,6 +288,7 @@ FocusScope {
287288 source: sortProxyModel
288289 sortBy: AppDrawerProxyModel.SortByAToZ
289290 group: AppDrawerProxyModel.GroupByAToZ
291+ dynamicSortFilter: false
290292 }
291293
292294 delegate: UbuntuShape {
@@ -320,6 +322,7 @@ FocusScope {
320322 id: categoryModel
321323 source: sortProxyModel
322324 filterLetter: model.letter
325+ dynamicSortFilter: false
323326 }
324327 delegateWidth: units.gu(8)
325328 delegateHeight: units.gu(10)