summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Hein <hein@kde.org>2017-02-16 12:46:22 (GMT)
committerEike Hein <hein@kde.org>2017-02-16 12:57:27 (GMT)
commit05826bd5ba25f6ed7be94ff8d760d6c8372f148c (patch)
treef663da3183804a3d45a04b31b22c9da7144b502a
parent410086d06bf0b6195030fec5e9ac848cc50f50a7 (diff)
Fix crash when switching activities.
Summary: What happens: * Activity switch calls invalidateFilter on TaskFilterProxyModel, which may remove rows in response. * Up the proxy chain, TasksModel may ask LauncherTasksModel to emit dataChanged for its contents in response to the row removal, to cause its own filtering to re-evaluate the launchers for the life cycle logic. * This can cause TFPM to do more filtering before invalidateFilter has actually returned, causing trip-ups such as duplicated rows in the proxy. * Eventually the corrupted maps cause a memory corruption crash. This patch changes step 2 to "find the launchers in the TFPM (the direct source model) and ask for a dataChanged for each". This costs us a loop and accesses to IsLauncher, but on the other hand fixes the crash and avoids a lot of filtering and mapping work between LTM and up to and including TFPM. It's also just better code to ask for the dataChanged only from the model we need it from. BUG:376055 Reviewers: #plasma, davidedmundson Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4631
-rw-r--r--libtaskmanager/tasksmodel.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp
index 7a49936..1937c3f 100644
--- a/libtaskmanager/tasksmodel.cpp
+++ b/libtaskmanager/tasksmodel.cpp
@@ -394,9 +394,13 @@ void TasksModel::Private::initModels()
Q_UNUSED(last)
if (launcherCheckNeeded) {
- QMetaObject::invokeMethod(launcherTasksModel, "dataChanged",
- Q_ARG(QModelIndex, launcherTasksModel->index(0, 0)),
- Q_ARG(QModelIndex, launcherTasksModel->index(launcherTasksModel->rowCount() - 1, 0)));
+ for (int i = 0; i < filterProxyModel->rowCount(); ++i) {
+ const QModelIndex &idx = filterProxyModel->index(i, 0);
+
+ if (idx.data(AbstractTasksModel::IsLauncher).toBool()) {
+ filterProxyModel->dataChanged(idx, idx);
+ }
+ }
launcherCheckNeeded = false;
}