From a095e4820366be672c9ee4d4e615cb2c0eaf3718 Mon Sep 17 00:00:00 2001 From: songwentao Date: Wed, 26 Oct 2022 11:24:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8D=B8=E8=BD=BD?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F=E5=B4=A9=E6=BA=83=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lambda表达式中错误使用引用 Log: Influence: 启动器-右键菜单-卸载应用,启动器可以正常进行操作 Bug: https://pms.uniontech.com/bug-view-165773.html Change-Id: I6126d14b7122ea95fece24a9cf9c9baa5f48da8a --- src/modules/launcher/launcher.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules/launcher/launcher.cpp b/src/modules/launcher/launcher.cpp index 7bd1f8b..3e4dfea 100644 --- a/src/modules/launcher/launcher.cpp +++ b/src/modules/launcher/launcher.cpp @@ -441,7 +441,7 @@ void Launcher::onHandleUninstall(const QDBusMessage &message) // 移除desktop文件 Item appItem = Item(); for (const Item &item : m_desktopAndItemMap) { - if (item.info.path == m_appInfo.getFileName().c_str()) { + if (item.info.path == QString::fromStdString(m_appInfo.getFileName())) { appItem = item; qDebug() << QString("app-%1 removed successfully").arg(item.info.name); break; @@ -1099,6 +1099,9 @@ void Launcher::uninstallApp(const QString &name, const QString &pkg) } QString servicePath = reply.value().path(); + + QDBusConnection::systemBus().disconnect(LASTORE_SERVICE, servicePath, "org.freedesktop.DBus.Properties", + "PropertiesChanged","sa{sv}as", this, SLOT(onHandleUninstall(const QDBusMessage &))); QDBusConnection::systemBus().connect(LASTORE_SERVICE, servicePath, "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(onHandleUninstall(const QDBusMessage &))); } @@ -1112,8 +1115,13 @@ bool Launcher::removeDesktop(const Item &item) { // 移除desktop文件 QFile file(item.info.path); + if (!file.exists()) { + qDebug() << "file not exist...item info: " << item.info; + return false; + } + bool ret = file.remove(); - std::thread thread([&] { + std::thread thread([ this, item, ret ] { notifyUninstallDone(item, ret); }); thread.detach(); @@ -1142,7 +1150,9 @@ void Launcher::removeAutoStart() { QString filePath(QDir::homePath() + "/.config/autostart/" + m_appInfo.getName().c_str() + ".desktop"); QFile file(filePath); - file.remove(); + + if (file.exists()) + file.remove(); } /**