Fix some leaking command job objects

This commit is contained in:
Marek Roszko 2022-11-09 22:40:05 -05:00
parent 43f039ef5f
commit 9b4505c6d2
3 changed files with 14 additions and 13 deletions

View File

@ -39,7 +39,8 @@ CLI::EXPORT_SCH_NETLIST_COMMAND::EXPORT_SCH_NETLIST_COMMAND() : EXPORT_PCB_BASE_
int CLI::EXPORT_SCH_NETLIST_COMMAND::Perform( KIWAY& aKiway )
{
JOB_EXPORT_SCH_NETLIST* netJob = new JOB_EXPORT_SCH_NETLIST( true );
std::unique_ptr<JOB_EXPORT_SCH_NETLIST> netJob =
std::make_unique<JOB_EXPORT_SCH_NETLIST>( true );
netJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
netJob->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
@ -81,7 +82,7 @@ int CLI::EXPORT_SCH_NETLIST_COMMAND::Perform( KIWAY& aKiway )
return EXIT_CODES::ERR_ARGS;
}
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, netJob );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, netJob.get() );
return exitCode;
}

View File

@ -56,7 +56,7 @@ CLI::EXPORT_SCH_PDF_COMMAND::EXPORT_SCH_PDF_COMMAND() : EXPORT_PCB_BASE_COMMAND(
int CLI::EXPORT_SCH_PDF_COMMAND::Perform( KIWAY& aKiway )
{
JOB_EXPORT_SCH_PDF* pdfJob = new JOB_EXPORT_SCH_PDF( true );
std::unique_ptr<JOB_EXPORT_SCH_PDF> pdfJob = std::make_unique<JOB_EXPORT_SCH_PDF>( true );
pdfJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
pdfJob->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
@ -72,7 +72,7 @@ int CLI::EXPORT_SCH_PDF_COMMAND::Perform( KIWAY& aKiway )
pdfJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, pdfJob );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, pdfJob.get() );
return exitCode;
}

View File

@ -56,23 +56,23 @@ CLI::EXPORT_SCH_SVG_COMMAND::EXPORT_SCH_SVG_COMMAND() : EXPORT_PCB_BASE_COMMAND(
int CLI::EXPORT_SCH_SVG_COMMAND::Perform( KIWAY& aKiway )
{
JOB_EXPORT_SCH_SVG* pdfJob = new JOB_EXPORT_SCH_SVG( true );
std::unique_ptr<JOB_EXPORT_SCH_SVG> svgJob = std::make_unique<JOB_EXPORT_SCH_SVG>( true );
pdfJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
pdfJob->m_outputDirectory = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
pdfJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
pdfJob->m_plotDrawingSheet = !m_argParser.get<bool>( ARG_EXCLUDE_DRAWING_SHEET );
pdfJob->m_useBackgroundColor = !m_argParser.get<bool>( ARG_NO_BACKGROUND_COLOR );
svgJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
svgJob->m_outputDirectory = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
svgJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
svgJob->m_plotDrawingSheet = !m_argParser.get<bool>( ARG_EXCLUDE_DRAWING_SHEET );
svgJob->m_useBackgroundColor = !m_argParser.get<bool>( ARG_NO_BACKGROUND_COLOR );
if( !wxFile::Exists( pdfJob->m_filename ) )
if( !wxFile::Exists( svgJob->m_filename ) )
{
wxFprintf( stderr, _( "Schematic file does not exist or is not accessible\n" ) );
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
}
pdfJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
svgJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, pdfJob );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, svgJob.get() );
return exitCode;
}