[libcalamares] Allow Runner instances to collect output

This commit is contained in:
Adriaan de Groot 2021-11-02 22:50:13 +01:00
parent 870009e815
commit 953b899f75
2 changed files with 14 additions and 10 deletions

View File

@ -94,12 +94,6 @@ namespace Calamares
namespace Utils
{
struct Runner::Private
{
QProcess m_process;
};
Runner::Runner() {}
@ -147,6 +141,20 @@ Calamares::Utils::Runner::run()
process.setArguments( m_command );
}
if ( m_output )
{
connect( &process, &QProcess::readyReadStandardOutput, [this, &process]() {
while ( process.canReadLine() )
{
QString s = process.readLine();
if ( !s.isEmpty() )
{
Q_EMIT this->output( s );
}
}
} );
}
cDebug() << Logger::SubEntry << "Running" << Logger::Redacted( m_command );
process.start();
if ( !process.waitForStarted() )

View File

@ -109,10 +109,6 @@ private:
QString m_input;
std::chrono::milliseconds m_timeout { 0 };
bool m_output = false;
// Internals for when it really does run
struct Private;
std::unique_ptr< Private > d;
};
} // namespace Utils