From 37f339c1c8c1a128e75cdd90e2fb8149482ae472 Mon Sep 17 00:00:00 2001 From: wjyrich Date: Tue, 11 Nov 2025 16:38:50 +0800 Subject: [PATCH] fix: add exact match flag to prevent duplicate app entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added Qt::MatchExactly flag to the match() function call to ensure proper duplicate detection This prevents multiple instances of the same application from being added to the model The previous implementation could incorrectly match partial desktop IDs, leading to duplicates fix: 添加精确匹配标志以防止重复应用条目 在 match() 函数调用中添加了 Qt::MatchExactly 标志以确保正确的重复检测 这可以防止同一应用程序的多个实例被添加到模型中 之前的实现可能会错误地匹配部分桌面 ID,导致重复条目 PMS: BUG-339005 --- applets/dde-apps/amappitemmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applets/dde-apps/amappitemmodel.cpp b/applets/dde-apps/amappitemmodel.cpp index 210d2e0e2..426ac9c13 100644 --- a/applets/dde-apps/amappitemmodel.cpp +++ b/applets/dde-apps/amappitemmodel.cpp @@ -32,7 +32,7 @@ AMAppItemModel::AMAppItemModel(QObject *parent) connect(m_manager, &ObjectManager::InterfacesAdded, this, [this](const QDBusObjectPath &objPath, ObjectInterfaceMap interfacesAndProperties) { auto desktopId = DUtil::unescapeFromObjectPath(objPath.path().split('/').last()); - if (!match(index(0, 0), AppItemModel::DesktopIdRole, desktopId).isEmpty()) { + if (!match(index(0, 0), AppItemModel::DesktopIdRole, desktopId, 1, Qt::MatchExactly).isEmpty()) { qCWarning(appsLog()) << "desktopId: " << desktopId << " already contains"; return; } @@ -42,7 +42,7 @@ AMAppItemModel::AMAppItemModel(QObject *parent) connect(m_manager, &ObjectManager::InterfacesRemoved, this, [this](const QDBusObjectPath &objPath, const QStringList &interfaces) { Q_UNUSED(interfaces) auto desktopId = DUtil::unescapeFromObjectPath(objPath.path().split('/').last()); - auto res = match(index(0, 0), AppItemModel::DesktopIdRole, desktopId); + auto res = match(index(0, 0), AppItemModel::DesktopIdRole, desktopId, 1, Qt::MatchExactly); if (res.isEmpty()) { qCWarning(appsLog()) << "failed find desktopId: " << desktopId; return;