7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

Use std::optional to better flag presence of arguments.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20460
This commit is contained in:
Jeff Young 2025-03-27 12:55:18 +00:00
parent 96835cbfcf
commit 8076bfa3c7
2 changed files with 31 additions and 30 deletions

View File

@ -43,8 +43,8 @@ public:
JOB_EXPORT_PCB_PLOT( PLOT_FORMAT aFormat, const std::string& aType, bool aOutputIsDirectory );
public:
wxString m_argLayers;
wxString m_argCommonLayers;
std::optional<wxString> m_argLayers;
std::optional<wxString> m_argCommonLayers;
PLOT_FORMAT m_plotFormat;

View File

@ -812,11 +812,11 @@ int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aSvgJob->m_plotLayerSequence.empty() )
{
aSvgJob->m_plotLayerSequence = convertLayerArg( aSvgJob->m_argLayers, brd );
aSvgJob->m_plotOnAllLayersSequence = convertLayerArg( aSvgJob->m_argCommonLayers, brd );
}
if( aSvgJob->m_argLayers )
aSvgJob->m_plotLayerSequence = convertLayerArg( aSvgJob->m_argLayers.value(), brd );
if( aSvgJob->m_argCommonLayers )
aSvgJob->m_plotOnAllLayersSequence = convertLayerArg( aSvgJob->m_argCommonLayers.value(), brd );
if( aSvgJob->m_plotLayerSequence.size() < 1 )
{
@ -873,11 +873,11 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aDxfJob->m_plotLayerSequence.empty() )
{
aDxfJob->m_plotLayerSequence = convertLayerArg( aDxfJob->m_argLayers, brd );
aDxfJob->m_plotOnAllLayersSequence = convertLayerArg( aDxfJob->m_argCommonLayers, brd );
}
if( aDxfJob->m_argLayers )
aDxfJob->m_plotLayerSequence = convertLayerArg( aDxfJob->m_argLayers.value(), brd );
if( aDxfJob->m_argCommonLayers )
aDxfJob->m_plotOnAllLayersSequence = convertLayerArg( aDxfJob->m_argCommonLayers.value(), brd );
if( aDxfJob->m_plotLayerSequence.size() < 1 )
{
@ -955,11 +955,11 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
brd->GetProject()->ApplyTextVars( pdfJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( pdfJob->m_plotLayerSequence.empty() )
{
pdfJob->m_plotLayerSequence = convertLayerArg( pdfJob->m_argLayers, brd );
pdfJob->m_plotOnAllLayersSequence = convertLayerArg( pdfJob->m_argCommonLayers, brd );
}
if( pdfJob->m_argLayers )
pdfJob->m_plotLayerSequence = convertLayerArg( pdfJob->m_argLayers.value(), brd );
if( pdfJob->m_argCommonLayers )
pdfJob->m_plotOnAllLayersSequence = convertLayerArg( pdfJob->m_argCommonLayers.value(), brd );
if( pdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE )
plotAllLayersOneFile = true;
@ -1052,16 +1052,17 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aGerberJob->m_plotLayerSequence.empty() )
if( aGerberJob->m_argLayers )
{
if( !aGerberJob->m_argLayers.empty() )
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers, nullptr );
if( !aGerberJob->m_argLayers.value().empty() )
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers.value(), nullptr );
else
aGerberJob->m_plotLayerSequence = LSET::AllLayersMask().SeqStackupForPlotting();
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers, brd );
}
if( aGerberJob->m_argCommonLayers )
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers.value(), brd );
PCB_PLOT_PARAMS boardPlotOptions = brd->GetPlotOptions();
GERBER_JOBFILE_WRITER jobfile_writer( brd );
@ -1280,11 +1281,11 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aGerberJob->m_plotLayerSequence.empty() )
{
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers, brd );
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers, brd );
}
if( aGerberJob->m_argLayers )
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers.value(), brd );
if( aGerberJob->m_argCommonLayers )
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers.value(), brd );
if( aGerberJob->m_plotLayerSequence.size() < 1 )
{
@ -1768,10 +1769,10 @@ int PCBNEW_JOBS_HANDLER::JobExportFpSvg( JOB* aJob )
PCB_IO_KICAD_SEXPR pcb_io( CTL_FOR_LIBRARY );
FP_CACHE fpLib( &pcb_io, svgJob->m_libraryPath );
if( svgJob->m_plotLayerSequence.empty() )
if( svgJob->m_argLayers )
{
if( !svgJob->m_argLayers.empty() )
svgJob->m_plotLayerSequence = convertLayerArg( svgJob->m_argLayers, nullptr );
if( !svgJob->m_argLayers.value().empty() )
svgJob->m_plotLayerSequence = convertLayerArg( svgJob->m_argLayers.value(), nullptr );
else
svgJob->m_plotLayerSequence = LSET::AllLayersMask().SeqStackupForPlotting();
}