From 39cc13cb25a04d96a1ce976afc41b571fe5526a4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 25 Jan 2020 15:23:10 +0100 Subject: [PATCH] [shellprocess] Tidy code - resolve TODO, use a unique_ptr to hang onto the command-list - sort the #includes, use correct quoting --- src/modules/shellprocess/ShellProcessJob.cpp | 16 ++++++---------- src/modules/shellprocess/ShellProcessJob.h | 16 ++++++++-------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/modules/shellprocess/ShellProcessJob.cpp b/src/modules/shellprocess/ShellProcessJob.cpp index ff73e83af..d0507a732 100644 --- a/src/modules/shellprocess/ShellProcessJob.cpp +++ b/src/modules/shellprocess/ShellProcessJob.cpp @@ -18,10 +18,6 @@ #include "ShellProcessJob.h" -#include -#include -#include - #include "CalamaresVersion.h" #include "GlobalStorage.h" #include "JobQueue.h" @@ -30,6 +26,10 @@ #include "utils/Logger.h" #include "utils/Variant.h" +#include +#include +#include + ShellProcessJob::ShellProcessJob( QObject* parent ) : Calamares::CppJob( parent ) , m_commands( nullptr ) @@ -37,11 +37,7 @@ ShellProcessJob::ShellProcessJob( QObject* parent ) } -ShellProcessJob::~ShellProcessJob() -{ - delete m_commands; - m_commands = nullptr; // TODO: UniquePtr -} +ShellProcessJob::~ShellProcessJob() {} QString @@ -77,7 +73,7 @@ ShellProcessJob::setConfigurationMap( const QVariantMap& configurationMap ) if ( configurationMap.contains( "script" ) ) { - m_commands = new CalamaresUtils::CommandList( + m_commands = std::make_unique< CalamaresUtils::CommandList >( configurationMap.value( "script" ), !dontChroot, std::chrono::seconds( timeout ) ); if ( m_commands->isEmpty() ) { diff --git a/src/modules/shellprocess/ShellProcessJob.h b/src/modules/shellprocess/ShellProcessJob.h index b9a255d95..d532aac99 100644 --- a/src/modules/shellprocess/ShellProcessJob.h +++ b/src/modules/shellprocess/ShellProcessJob.h @@ -19,16 +19,16 @@ #ifndef SHELLPROCESSJOB_H #define SHELLPROCESSJOB_H +#include "CppJob.h" +#include "PluginDllMacro.h" + +#include "utils/CommandList.h" +#include "utils/PluginFactory.h" + #include #include -#include - -#include -#include - -#include - +#include class PLUGINDLLEXPORT ShellProcessJob : public Calamares::CppJob { @@ -45,7 +45,7 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; private: - CalamaresUtils::CommandList* m_commands; + std::unique_ptr< CalamaresUtils::CommandList > m_commands; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( ShellProcessJobFactory )