summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Hein <hein@kde.org>2017-03-31 10:15:43 (GMT)
committerEike Hein <hein@kde.org>2017-03-31 10:21:39 (GMT)
commit628593db4c65560ace95759ffca5ce0920de621e (patch)
tree728a456b66db4a0eee0a135f933e1dd623ae5747
parent34b74d7b5dac9dd458a960e392954ac6c30df3d2 (diff)
Fix TasksModel.anyTaskDemandsAttention not updating on window closure.
Summary: Previously we updated the prop after checking for AbstractTasksModel::IsDemandingAttention on window closure, but as the window is gone, we can't actually get state for it anymore, so we always need to update. To make up for it, this patch also optimizes the prop updates to occur only once per insert/remove batch - this is a bit academic because the source models currently only insert single rows at a time, but it's good hygiene. BUG:378254 Reviewers: #plasma, mart Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D5261
-rw-r--r--libtaskmanager/tasksmodel.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp
index b458c50..3955235 100644
--- a/libtaskmanager/tasksmodel.cpp
+++ b/libtaskmanager/tasksmodel.cpp
@@ -305,12 +305,14 @@ void TasksModel::Private::initModels()
return;
}
+ bool demandsAttentionUpdateNeeded = false;
+
for (int i = first; i <= last; ++i) {
const QModelIndex &sourceIndex = groupingProxyModel->index(i, 0);
const QString &appId = sourceIndex.data(AbstractTasksModel::AppId).toString();
if (sourceIndex.data(AbstractTasksModel::IsDemandingAttention).toBool()) {
- updateAnyTaskDemandsAttention();
+ demandsAttentionUpdateNeeded = true;
}
// When we get a window we have a startup for, cause the startup to be re-filtered.
@@ -347,6 +349,10 @@ void TasksModel::Private::initModels()
}
}
}
+
+ if (!anyTaskDemandsAttention && demandsAttentionUpdateNeeded) {
+ updateAnyTaskDemandsAttention();
+ }
}
);
@@ -360,10 +366,6 @@ void TasksModel::Private::initModels()
for (int i = first; i <= last; ++i) {
const QModelIndex &sourceIndex = groupingProxyModel->index(i, 0);
- if (sourceIndex.data(AbstractTasksModel::IsDemandingAttention).toBool()) {
- updateAnyTaskDemandsAttention();
- }
-
// When a window or startup task is removed, we have to trigger a re-filter of
// our launchers to (possibly) pop them back in.
// NOTE: An older revision of this code compared the window and startup tasks
@@ -404,6 +406,13 @@ void TasksModel::Private::initModels()
launcherCheckNeeded = false;
}
+
+ // One of the removed tasks might have been demanding attention, but
+ // we can't check the state after the window has been closed already,
+ // so we always have to do a full update.
+ if (anyTaskDemandsAttention) {
+ updateAnyTaskDemandsAttention();
+ }
}
);