fix: update location after insertion
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
b75bb395fd
commit
2fb5567eaf
@ -257,23 +257,24 @@ QDBusObjectPath ApplicationService::Launch(const QString &action, const QStringL
|
|||||||
auto &jobManager = parent()->jobManager();
|
auto &jobManager = parent()->jobManager();
|
||||||
return jobManager.addJob(
|
return jobManager.addJob(
|
||||||
m_applicationPath.path(),
|
m_applicationPath.path(),
|
||||||
[this, binary = std::move(bin), commands = std::move(cmds)](const QVariant &variantValue) mutable -> QVariant {
|
[this, binary = std::move(bin), commands = std::move(cmds)](const QVariant &variantValue) -> QVariant {
|
||||||
auto resourceFile = variantValue.toString();
|
auto resourceFile = variantValue.toString();
|
||||||
auto instanceRandomUUID = QUuid::createUuid().toString(QUuid::Id128);
|
auto instanceRandomUUID = QUuid::createUuid().toString(QUuid::Id128);
|
||||||
auto objectPath = m_applicationPath.path() + "/" + instanceRandomUUID;
|
auto objectPath = m_applicationPath.path() + "/" + instanceRandomUUID;
|
||||||
commands.push_front(QString{"--SourcePath=%1"}.arg(m_desktopSource.sourcePath()));
|
auto newCommands = commands;
|
||||||
|
|
||||||
auto location = commands.indexOf(R"(%f)");
|
newCommands.push_front(QString{"--SourcePath=%1"}.arg(m_desktopSource.sourcePath()));
|
||||||
|
auto location = newCommands.indexOf(R"(%f)");
|
||||||
if (location != -1) { // due to std::move, there only remove once
|
if (location != -1) { // due to std::move, there only remove once
|
||||||
commands.remove(location);
|
newCommands.remove(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resourceFile.isEmpty()) {
|
if (resourceFile.isEmpty()) {
|
||||||
commands.push_front(QString{R"(--unitName=app-DDE-%1@%2.service)"}.arg(
|
newCommands.push_front(QString{R"(--unitName=app-DDE-%1@%2.service)"}.arg(
|
||||||
escapeApplicationId(this->id()), instanceRandomUUID)); // launcher should use this instanceId
|
escapeApplicationId(this->id()), instanceRandomUUID)); // launcher should use this instanceId
|
||||||
QProcess process;
|
QProcess process;
|
||||||
qDebug() << "run with commands:" << commands;
|
qDebug() << "run with commands:" << newCommands;
|
||||||
process.start(m_launcher, commands);
|
process.start(m_launcher, newCommands);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
if (auto code = process.exitCode(); code != 0) {
|
if (auto code = process.exitCode(); code != 0) {
|
||||||
qWarning() << "Launch Application Failed";
|
qWarning() << "Launch Application Failed";
|
||||||
@ -291,11 +292,12 @@ QDBusObjectPath ApplicationService::Launch(const QString &action, const QStringL
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: resourceFile must be available in the following contexts
|
// NOTE: resourceFile must be available in the following contexts
|
||||||
commands.insert(location, resourceFile);
|
newCommands.insert(location, resourceFile);
|
||||||
commands.push_front(QString{R"(--unitName=DDE-%1@%2.service)"}.arg(this->id(), instanceRandomUUID));
|
|
||||||
|
newCommands.push_front(QString{R"(--unitName=DDE-%1@%2.service)"}.arg(this->id(), instanceRandomUUID));
|
||||||
QProcess process;
|
QProcess process;
|
||||||
qDebug() << "run with commands:" << commands;
|
qDebug() << "run with commands:" << newCommands;
|
||||||
process.start(getApplicationLauncherBinary(), commands);
|
process.start(getApplicationLauncherBinary(), newCommands);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
auto exitCode = process.exitCode();
|
auto exitCode = process.exitCode();
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
@ -909,6 +911,7 @@ LaunchTask ApplicationService::unescapeExec(const QString &str, const QStringLis
|
|||||||
auto it = execList.begin() + location;
|
auto it = execList.begin() + location;
|
||||||
for (const auto &field : fields) {
|
for (const auto &field : fields) {
|
||||||
it = execList.insert(it, field);
|
it = execList.insert(it, field);
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
task.command.append(std::move(execList));
|
task.command.append(std::move(execList));
|
||||||
} break;
|
} break;
|
||||||
|
Loading…
Reference in New Issue
Block a user