fix: 修复卸载应用程序崩溃问题

lambda表达式中错误使用引用

Log:
Influence: 启动器-右键菜单-卸载应用,启动器可以正常进行操作
Bug: https://pms.uniontech.com/bug-view-165773.html
Change-Id: I6126d14b7122ea95fece24a9cf9c9baa5f48da8a
This commit is contained in:
songwentao 2022-10-26 11:24:12 +08:00
parent dd9b28a021
commit a095e48203

View File

@ -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,6 +1150,8 @@ void Launcher::removeAutoStart()
{
QString filePath(QDir::homePath() + "/.config/autostart/" + m_appInfo.getName().c_str() + ".desktop");
QFile file(filePath);
if (file.exists())
file.remove();
}