Do not reuse QProcess object in externalcommandhelper for different invocations.
This commit is contained in:
parent
fae9f83451
commit
d16d9e8019
|
@ -284,15 +284,16 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr
|
||||||
|
|
||||||
// connect(&cmd, &QProcess::readyReadStandardOutput, this, &ExternalCommandHelper::onReadOutput);
|
// connect(&cmd, &QProcess::readyReadStandardOutput, this, &ExternalCommandHelper::onReadOutput);
|
||||||
|
|
||||||
m_cmd.setEnvironment( { QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1") } );
|
QProcess cmd;
|
||||||
m_cmd.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(processChannelMode));
|
cmd.setEnvironment( { QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1") } );
|
||||||
m_cmd.start(command, arguments);
|
cmd.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(processChannelMode));
|
||||||
m_cmd.write(input);
|
cmd.start(command, arguments);
|
||||||
m_cmd.closeWriteChannel();
|
cmd.write(input);
|
||||||
m_cmd.waitForFinished(-1);
|
cmd.closeWriteChannel();
|
||||||
QByteArray output = m_cmd.readAllStandardOutput();
|
cmd.waitForFinished(-1);
|
||||||
|
QByteArray output = cmd.readAllStandardOutput();
|
||||||
reply[QStringLiteral("output")] = output;
|
reply[QStringLiteral("output")] = output;
|
||||||
reply[QStringLiteral("exitCode")] = m_cmd.exitCode();
|
reply[QStringLiteral("exitCode")] = cmd.exitCode();
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ private:
|
||||||
bool isCallerAuthorized();
|
bool isCallerAuthorized();
|
||||||
|
|
||||||
void onReadOutput();
|
void onReadOutput();
|
||||||
QProcess m_cmd;
|
|
||||||
QDBusServiceWatcher *m_serviceWatcher = nullptr;
|
QDBusServiceWatcher *m_serviceWatcher = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue