From fa00ca6a012faab30a9596a50a1b82f02e3e5c4e Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Sun, 4 Oct 2020 21:17:56 +0200 Subject: [PATCH] [libtaskmanager] Fix incorrect URL comparison when writing back a new launcher order When computing the delta between the visible and the last saved launcher order state, following the reordering of launchers, the code was incorrectly comparing resolved and unresolved (i.e., for config storage) launcher URLs. This lead to an incorrect result and therefore pinned tasks jumping around in the Task Manager applet. BUG:426880 --- libtaskmanager/tasksmodel.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp index 5ec84e966..3ce71f54d 100644 --- a/libtaskmanager/tasksmodel.cpp +++ b/libtaskmanager/tasksmodel.cpp @@ -1773,7 +1773,17 @@ void TasksModel::syncLaunchers() for (int i = 0; i < rowCount(); ++i) { const QUrl &rowLauncherUrl = index(i, 0).data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl(); - if (launcherUrlsMatch(launcherUrl, rowLauncherUrl, IgnoreQueryItems)) { + // `LauncherTasksModel::launcherList()` returns data in a format suitable for writing + // to persistent configuration storage, e.g. `preferred://browser`. We mean to compare + // this last "save state" to a higher, resolved URL representation to compute the delta + // so we need to move the unresolved URLs through `TaskTools::appDataFromUrl()` first. + // TODO: This bypasses an existing lookup cache for the resolved app data that exists + // in LauncherTasksModel. It's likely a good idea to eventually move these caches out + // of the various models and share them among users of `TaskTools::appDataFromUrl()`, + // and then also do resolution implicitly in `TaskTools::launcherUrlsMatch`, to speed + // things up slightly and make the models simpler (central cache eviction, ...). + if (launcherUrlsMatch(appDataFromUrl(launcherUrl).url, + rowLauncherUrl, IgnoreQueryItems)) { row = i; break; }