From e43d73be265c82faac05d5a211c5fd30931a629c Mon Sep 17 00:00:00 2001 From: BLumia Date: Wed, 14 Oct 2026 18:19:25 +0800 Subject: [PATCH] fix: remove endsWith(.desktop) heuristic in normalizedDesktopId MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: normalizedDesktopId() used endsWith(".desktop") to skip appending the suffix, but AM DBus appId always lacks the .desktop extension; for org.telegram.desktop the check returned true, so GIO got org.telegram.desktop instead of org.telegram.desktop.desktop and returned NULL 2. Fix: remove the endsWith(".desktop") condition; always append .desktop unless the source is empty or starts with internal/ 3. Impact: apps whose appId ends with .desktop (e.g. Telegram linyaps) can now be uninstalled, launched, and docked correctly; no regression for normal apps or BUG-378253 fix Log: Fixed linyaps apps with .desktop suffix in app ID cannot be uninstalled from launcher Influence: 1. Test uninstalling linyaps apps with .desktop suffix in app ID 2. Test launching linyaps apps with .desktop suffix in app ID 3. Test dock operations for linyaps apps with .desktop suffix 4. Test normal apps without .desktop suffix still work correctly fix: 移除 normalizedDesktopId 中的 endsWith(.desktop) 启发式判断 1. 根因:normalizedDesktopId() 使用 endsWith(".desktop") 跳过后缀 追加,但 AM DBus appId 始终不含 .desktop 后缀;对 org.telegram.desktop 该判断返回 true,导致 GIO 收到 org.telegram.desktop 而非 org.telegram.desktop.desktop,返回 NULL 2. 方案:移除 endsWith(".desktop") 条件,仅在 source 为空或以 internal/ 开头时跳过后缀追加 3. 影响:appId 以 .desktop 结尾的玲珑应用(如 Telegram)可正常 卸载、启动和驻留;对普通应用及 BUG-378253 修复无回归 Log: 修复玲珑应用 appId 含 .desktop 后缀时启动器无法卸载的问题 Influence: 1. 测试 appId 含 .desktop 后缀的玲珑应用卸载功能 2. 测试 appId 含 .desktop 后缀的玲珑应用启动功能 3. 测试 appId 含 .desktop 后缀的玲珑应用驻留操作 4. 测试不含 .desktop 后缀的普通应用功能无回归 PMS: BUG-379545 --- src/models/appsmodel.cpp | 2 +- tests/searchfilterproxymodeltest.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/appsmodel.cpp b/src/models/appsmodel.cpp index 23ecef10..f2086062 100644 --- a/src/models/appsmodel.cpp +++ b/src/models/appsmodel.cpp @@ -293,7 +293,7 @@ QList AppsModel::mappedRoles(const QList &sourceRoles) const QString AppsModel::normalizedDesktopId(const QString &sourceId) { - if (sourceId.isEmpty() || sourceId.endsWith(QLatin1String(".desktop")) || sourceId.startsWith(QLatin1String("internal/"))) + if (sourceId.isEmpty() || sourceId.startsWith(QLatin1String("internal/"))) return sourceId; return sourceId + QStringLiteral(".desktop"); } diff --git a/tests/searchfilterproxymodeltest.cpp b/tests/searchfilterproxymodeltest.cpp index 16552c84..06fa5695 100644 --- a/tests/searchfilterproxymodeltest.cpp +++ b/tests/searchfilterproxymodeltest.cpp @@ -382,16 +382,16 @@ void TestSearchFilterProxyModel::testSharedModelAdapter() QCOMPARE(appsModel.indexFromDesktopId("org.test.hidden.desktop").data(AppsModel::DesktopIdRole).toString(), QStringLiteral("org.test.hidden")); - auto suffixedItem = createTestAppItem("org.test.suffixed.desktop", "Suffixed", "Suffixed"); + auto suffixedItem = createTestAppItem("org.test.suffixed", "Suffixed", "Suffixed"); m_sourceModel.appendRow(suffixedItem); QCOMPARE(rowsInsertedSpy.count(), 2); const QModelIndex suffixedIndex = appsModel.indexFromDesktopId("org.test.suffixed"); QCOMPARE(suffixedIndex.data(AppsModel::DesktopIdRole).toString(), - QStringLiteral("org.test.suffixed.desktop")); + QStringLiteral("org.test.suffixed")); QSignalSpy dataChangedSpy(&appsModel, &QAbstractItemModel::dataChanged); suffixedItem->setData(QStringLiteral("Renamed"), SourceNameRole); - QCOMPARE(appsModel.indexFromDesktopId("org.test.suffixed.desktop").data(Qt::DisplayRole).toString(), + QCOMPARE(appsModel.indexFromDesktopId("org.test.suffixed").data(Qt::DisplayRole).toString(), QStringLiteral("Renamed")); QVERIFY(!dataChangedSpy.isEmpty()); const auto changedRoles = dataChangedSpy.constLast().at(2).value>();