[shellprocess] Tidy code

- resolve TODO, use a unique_ptr to hang onto the command-list
 - sort the #includes, use correct quoting
This commit is contained in:
Adriaan de Groot 2020-01-25 15:23:10 +01:00
parent 71a73ee1a1
commit 39cc13cb25
2 changed files with 14 additions and 18 deletions

View File

@ -18,10 +18,6 @@
#include "ShellProcessJob.h" #include "ShellProcessJob.h"
#include <QDateTime>
#include <QProcess>
#include <QThread>
#include "CalamaresVersion.h" #include "CalamaresVersion.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
@ -30,6 +26,10 @@
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Variant.h" #include "utils/Variant.h"
#include <QDateTime>
#include <QProcess>
#include <QThread>
ShellProcessJob::ShellProcessJob( QObject* parent ) ShellProcessJob::ShellProcessJob( QObject* parent )
: Calamares::CppJob( parent ) : Calamares::CppJob( parent )
, m_commands( nullptr ) , m_commands( nullptr )
@ -37,11 +37,7 @@ ShellProcessJob::ShellProcessJob( QObject* parent )
} }
ShellProcessJob::~ShellProcessJob() ShellProcessJob::~ShellProcessJob() {}
{
delete m_commands;
m_commands = nullptr; // TODO: UniquePtr
}
QString QString
@ -77,7 +73,7 @@ ShellProcessJob::setConfigurationMap( const QVariantMap& configurationMap )
if ( configurationMap.contains( "script" ) ) if ( configurationMap.contains( "script" ) )
{ {
m_commands = new CalamaresUtils::CommandList( m_commands = std::make_unique< CalamaresUtils::CommandList >(
configurationMap.value( "script" ), !dontChroot, std::chrono::seconds( timeout ) ); configurationMap.value( "script" ), !dontChroot, std::chrono::seconds( timeout ) );
if ( m_commands->isEmpty() ) if ( m_commands->isEmpty() )
{ {

View File

@ -19,16 +19,16 @@
#ifndef SHELLPROCESSJOB_H #ifndef SHELLPROCESSJOB_H
#define SHELLPROCESSJOB_H #define SHELLPROCESSJOB_H
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "utils/CommandList.h"
#include "utils/PluginFactory.h"
#include <QObject> #include <QObject>
#include <QVariantMap> #include <QVariantMap>
#include <CppJob.h> #include <memory>
#include <utils/CommandList.h>
#include <utils/PluginFactory.h>
#include <PluginDllMacro.h>
class PLUGINDLLEXPORT ShellProcessJob : public Calamares::CppJob class PLUGINDLLEXPORT ShellProcessJob : public Calamares::CppJob
{ {
@ -45,7 +45,7 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override; void setConfigurationMap( const QVariantMap& configurationMap ) override;
private: private:
CalamaresUtils::CommandList* m_commands; std::unique_ptr< CalamaresUtils::CommandList > m_commands;
}; };
CALAMARES_PLUGIN_FACTORY_DECLARATION( ShellProcessJobFactory ) CALAMARES_PLUGIN_FACTORY_DECLARATION( ShellProcessJobFactory )