Skip to content

Commit 37f339c

Browse files
committed
fix: add exact match flag to prevent duplicate app entries
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
1 parent 7e29b38 commit 37f339c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

applets/dde-apps/amappitemmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ AMAppItemModel::AMAppItemModel(QObject *parent)
3232

3333
connect(m_manager, &ObjectManager::InterfacesAdded, this, [this](const QDBusObjectPath &objPath, ObjectInterfaceMap interfacesAndProperties) {
3434
auto desktopId = DUtil::unescapeFromObjectPath(objPath.path().split('/').last());
35-
if (!match(index(0, 0), AppItemModel::DesktopIdRole, desktopId).isEmpty()) {
35+
if (!match(index(0, 0), AppItemModel::DesktopIdRole, desktopId, 1, Qt::MatchExactly).isEmpty()) {
3636
qCWarning(appsLog()) << "desktopId: " << desktopId << " already contains";
3737
return;
3838
}
@@ -42,7 +42,7 @@ AMAppItemModel::AMAppItemModel(QObject *parent)
4242
connect(m_manager, &ObjectManager::InterfacesRemoved, this, [this](const QDBusObjectPath &objPath, const QStringList &interfaces) {
4343
Q_UNUSED(interfaces)
4444
auto desktopId = DUtil::unescapeFromObjectPath(objPath.path().split('/').last());
45-
auto res = match(index(0, 0), AppItemModel::DesktopIdRole, desktopId);
45+
auto res = match(index(0, 0), AppItemModel::DesktopIdRole, desktopId, 1, Qt::MatchExactly);
4646
if (res.isEmpty()) {
4747
qCWarning(appsLog()) << "failed find desktopId: " << desktopId;
4848
return;

0 commit comments

Comments
 (0)