fix: 修复从桌面和启动器无法打开浏览器(玲珑)的问题
玲珑应用Desktop文件Exec字段内容构成的字符串中包含字串,且字串不允许被拆分 对接玲珑组开发人员后,由AM对该问题进行修复 Log: Influence: 从桌面和启动器都可以正常打开浏览器(玲珑)应用 Task: https://pms.uniontech.com/task-view-236197.html Change-Id: I874bb3b9ba5d9d086279857e8d826b04e0a7ab58
This commit is contained in:
		@ -343,7 +343,7 @@ bool StartManager::doLaunchAppWithOptions(const QString &desktopFile)
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    launch(&info, QString::fromStdString(info.getCommandLine()).remove("\""), 0, QStringList());
 | 
			
		||||
    launch(&info, QString::fromStdString(info.getCommandLine()), 0, QStringList());
 | 
			
		||||
 | 
			
		||||
    dbusHandler->markLaunched(desktopFile);
 | 
			
		||||
 | 
			
		||||
@ -372,7 +372,7 @@ bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestam
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    launch(&info,  QString::fromStdString(info.getCommandLine()).remove("\""), timestamp, files);
 | 
			
		||||
    launch(&info, info.getCommandLine().c_str(), timestamp, files);
 | 
			
		||||
 | 
			
		||||
    // mark app launched
 | 
			
		||||
    dbusHandler->markLaunched(desktopFile);
 | 
			
		||||
@ -382,6 +382,21 @@ bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestam
 | 
			
		||||
 | 
			
		||||
bool StartManager::launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files)
 | 
			
		||||
{
 | 
			
		||||
    /// 玲珑应用-浏览器应用比较特殊,Exec字段内容字符串中包含子串,且以空格分割时会导致浏览器无法启动的问题
 | 
			
		||||
    /// 与玲珑组开发对接,他们暂无有效方式优化该问题,AM 从自身Exec字段内容特点进行解析,修复该问题
 | 
			
		||||
    /// \brief subExecPos
 | 
			
		||||
    ///
 | 
			
		||||
    const int subExecPos = cmdLine.indexOf("--exec", 0);
 | 
			
		||||
    const QString subArgStr = cmdLine.mid(subExecPos);
 | 
			
		||||
 | 
			
		||||
    // 保留字符串头部的转移字符\"
 | 
			
		||||
    const QString subExecArgStr = subArgStr.section("\"", 1, 2, QString::SectionIncludeLeadingSep);
 | 
			
		||||
    // 保留字符串尾部的转移字符\"
 | 
			
		||||
    const QString subStr = subExecArgStr.section("\"", 0, 1, QString::SectionIncludeTrailingSep).remove("\"");
 | 
			
		||||
 | 
			
		||||
    // 从Exec字段内容中移除引号
 | 
			
		||||
    cmdLine.remove("\"");
 | 
			
		||||
 | 
			
		||||
    QProcess process;
 | 
			
		||||
    QStringList cmdPrefixesEnvs;
 | 
			
		||||
    QStringList envs;
 | 
			
		||||
@ -416,6 +431,20 @@ bool StartManager::launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp
 | 
			
		||||
    QStringList exeArgs;
 | 
			
		||||
    exeArgs << cmdLine.split(" ");
 | 
			
		||||
 | 
			
		||||
    // 如果Exec字段内容字符串中包含子字符串,则要确保子串的内容不被分割
 | 
			
		||||
    // 先从被分割的列表中移除重复字段,然后将--Exec后面的子串内容整体插入
 | 
			
		||||
    if (!subStr.isEmpty()) {
 | 
			
		||||
        QStringList tempExeArgs = exeArgs;
 | 
			
		||||
        for (const QString &arg : exeArgs) {
 | 
			
		||||
            if (subStr.contains(arg))
 | 
			
		||||
                tempExeArgs.removeOne(arg);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        exeArgs = tempExeArgs;
 | 
			
		||||
        int pos = exeArgs.indexOf("--exec");
 | 
			
		||||
        exeArgs.insert(pos + 1, subStr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    handleRecognizeArgs(exeArgs, files);
 | 
			
		||||
 | 
			
		||||
    if (info->getTerminal()) {
 | 
			
		||||
@ -428,11 +457,14 @@ bool StartManager::launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp
 | 
			
		||||
        workingDir = BaseDir::homeDir();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString exec = exeArgs[0];
 | 
			
		||||
    exeArgs.removeAt(0);
 | 
			
		||||
    QString exec;
 | 
			
		||||
    if (!exeArgs.isEmpty()) {
 | 
			
		||||
        exec = exeArgs[0];
 | 
			
		||||
        exeArgs.removeAt(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#ifdef QT_DEBUG
 | 
			
		||||
    qDebug() << "launchApp: " << desktopFile << " exec:  " << exec << " args:   " << exeArgs;
 | 
			
		||||
        qInfo() << "launchApp: " << desktopFile << " exec:  " << exec << " args:   " << exeArgs;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    process.setWorkingDirectory(workingDir.c_str());
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user