From 82b4b70f6ff2df914c8cd02a4af3f4d5e9875350 Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Sun, 4 Oct 2020 21:23:49 +0200 Subject: [PATCH] [libtaskmanager] Remove a poorly conceived optimization The LauncherTasksModel tried to avoid a model reset by making certain assumptions to save a few cycles. Ultimately this was misguided, in- correctly not evicting the internal app data cache as well as causing a lot more work in the view trying to compute layout deltas and some- times causing a few frames of ugly animations. There likely _is_ some optimization potential here, but it needs to be done smarter later on. (cherry picked from commit 40d7df210fbc77cce08c0a9a5249a0d85d03e979) --- libtaskmanager/launchertasksmodel.cpp | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/libtaskmanager/launchertasksmodel.cpp b/libtaskmanager/launchertasksmodel.cpp index 5be31b751..63a493d1c 100644 --- a/libtaskmanager/launchertasksmodel.cpp +++ b/libtaskmanager/launchertasksmodel.cpp @@ -475,31 +475,14 @@ void LauncherTasksModel::setLauncherList(const QStringList &serializedLaunchers) if (newLaunchersOrder != d->launchersOrder || newActivitiesForLauncher != d->activitiesForLauncher) { - // Common case optimization: If the list changed but its size - // did not (e.g. due to reordering by a user of this model), - // just clear the caches and announce new data instead of - // resetting. - if (newLaunchersOrder.count() == d->launchersOrder.count()) { - d->appDataCache.clear(); + beginResetModel(); - std::swap(newLaunchersOrder, d->launchersOrder); - std::swap(newActivitiesForLauncher, d->activitiesForLauncher); + std::swap(newLaunchersOrder, d->launchersOrder); + std::swap(newActivitiesForLauncher, d->activitiesForLauncher); - emit dataChanged( - index(0, 0), - index(d->launchersOrder.count() - 1, 0)); + d->appDataCache.clear(); - } else { - beginResetModel(); - - std::swap(newLaunchersOrder, d->launchersOrder); - std::swap(newActivitiesForLauncher, d->activitiesForLauncher); - - d->appDataCache.clear(); - - endResetModel(); - - } + endResetModel(); emit launcherListChanged(); }