From 1776fa95d5b5183b27599e61b52a78d4f2ebb3b9 Mon Sep 17 00:00:00 2001 From: ComixHe Date: Wed, 6 Sep 2023 17:47:31 +0800 Subject: [PATCH] fix: interfaceRemoved isn't be emit after application uninstall Signed-off-by: ComixHe --- src/dbus/applicationmanager1service.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/dbus/applicationmanager1service.cpp b/src/dbus/applicationmanager1service.cpp index 0583453..662bc74 100644 --- a/src/dbus/applicationmanager1service.cpp +++ b/src/dbus/applicationmanager1service.cpp @@ -343,7 +343,9 @@ void ApplicationManager1Service::ReloadApplications() { const auto &desktopFileDirs = getDesktopFileDirs(); - applyIteratively(QList(desktopFileDirs.cbegin(), desktopFileDirs.cend()), [this](const QFileInfo &info) -> bool { + auto apps = m_applicationList.keys(); + + applyIteratively(QList(desktopFileDirs.cbegin(), desktopFileDirs.cend()), [this, &apps](const QFileInfo &info) -> bool { DesktopErrorCode err{DesktopErrorCode::NoError}; auto ret = DesktopFile::searchDesktopFileByPath(info.absoluteFilePath(), err); if (!ret.has_value()) { @@ -357,15 +359,13 @@ void ApplicationManager1Service::ReloadApplications() m_applicationList.cend(), [&file](const QSharedPointer &app) { return file.desktopId() == app->id(); }); - if (err == DesktopErrorCode::NotFound) { - if (destApp != m_applicationList.cend()) { - removeOneApplication(destApp.key()); - } - qWarning() << "failed to search File:" << err << "skip."; + if (err != DesktopErrorCode::NoError) { + qWarning() << "error occurred:" << err << " skip this application."; return false; } if (destApp != m_applicationList.cend()) { + apps.removeOne(destApp.key()); updateApplication(destApp.value(), file); return false; } @@ -373,6 +373,10 @@ void ApplicationManager1Service::ReloadApplications() addApplication(std::move(file)); return false; }); + + for (const auto &key : apps) { + removeOneApplication(key); + } } ObjectMap ApplicationManager1Service::GetManagedObjects() const