diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index 6429047d5a..2c6b241d12 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -2,7 +2,7 @@ * This file is part of libeval, a simple math expression evaluator * * Copyright (C) 2017 Michael Geselbracht, mgeselbracht3@gmail.com - * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -356,10 +356,11 @@ void COMPILER::newString( const wxString& aString ) m_parseFinished = false; } + T_TOKEN COMPILER::getToken() { T_TOKEN rv; - rv.value.str = nullptr; + rv.value = defaultTokenValue; bool done = false; diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index 05697a2aef..ddc44b58ca 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -1160,6 +1160,9 @@ void DIALOG_SIM_MODEL::onDifferentialCheckbox( wxCommandEvent if( isIbisLoaded() ) { SIM_MODEL_KIBIS* modelkibis = dynamic_cast( &curModel() ); + + wxCHECK( modelkibis, /* void */ ); + bool diff = m_differentialCheckbox->GetValue() && modelkibis->CanDifferential(); modelkibis->SwitchSingleEndedDiff( diff ); } diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 4287399832..00319f4ac6 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -1079,6 +1079,9 @@ bool SIM_MODEL::requiresSpiceModelLine( const SPICE_ITEM& aItem ) const continue; const SIM_MODEL* baseModel = dynamic_cast( m_baseModel ); + + wxCHECK( baseModel, false ); + std::string baseValue = baseModel->m_params[ii].value; if( param.value == baseValue ) @@ -1734,6 +1737,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) if( spiceTypeInfo.m_Text == wxT( "DC" ) && tokenizer.CountTokens() == 1 ) { + wxCHECK( valueField, /* void */ ); valueField->SetText( tokenizer.GetNextToken() ); modelFromValueField = false; } diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index 00d80a1289..be0f806dea 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -52,6 +52,7 @@ #include "pcbnew_scripting_helpers.h" + PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER() { Register( "step", @@ -183,10 +184,10 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob ) { plotOpts.SetDXFPlotUnits( DXF_UNITS::INCHES ); } + plotOpts.SetPlotFrameRef( aDxfJob->m_plotBorderTitleBlocks ); plotOpts.SetPlotValue( aDxfJob->m_plotFootprintValues ); plotOpts.SetPlotReference( aDxfJob->m_plotRefDes ); - plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer ); DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard( @@ -353,6 +354,7 @@ void PCBNEW_JOBS_HANDLER::populateGerberPlotOptionsFromJob( PCB_PLOT_PARAMS& aPlotOpts.SetPlotReference( aJob->m_plotRefDes ); aPlotOpts.SetSubtractMaskFromSilk( aJob->m_subtractSolderMaskFromSilk ); + // Always disable plot pad holes aPlotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE ); @@ -409,6 +411,7 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob ) static DRILL_PRECISION precisionListForInches( 2, 4 ); static DRILL_PRECISION precisionListForMetric( 3, 3 ); + int PCBNEW_JOBS_HANDLER::JobExportDrill( JOB* aJob ) { JOB_EXPORT_PCB_DRILL* aDrillJob = dynamic_cast( aJob ); @@ -422,6 +425,7 @@ int PCBNEW_JOBS_HANDLER::JobExportDrill( JOB* aJob ) BOARD* brd = LoadBoard( aDrillJob->m_filename ); std::unique_ptr drillWriter; + if( aDrillJob->m_format == JOB_EXPORT_PCB_DRILL::DRILL_FORMAT::EXCELLON ) { drillWriter = std::make_unique( brd ); @@ -432,13 +436,14 @@ int PCBNEW_JOBS_HANDLER::JobExportDrill( JOB* aJob ) } VECTOR2I offset; + if( aDrillJob->m_drillOrigin == JOB_EXPORT_PCB_DRILL::DRILL_ORIGIN::ABSOLUTE ) offset = VECTOR2I( 0, 0 ); else offset = brd->GetDesignSettings().GetAuxOrigin(); - PLOT_FORMAT mapFormat = PLOT_FORMAT::PDF; + switch( aDrillJob->m_mapFormat ) { case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::POSTSCRIPT: mapFormat = PLOT_FORMAT::POST; break; @@ -470,27 +475,36 @@ int PCBNEW_JOBS_HANDLER::JobExportDrill( JOB* aJob ) } DRILL_PRECISION precision; + if( aDrillJob->m_drillUnits == JOB_EXPORT_PCB_DRILL::DRILL_UNITS::INCHES ) precision = precisionListForInches; else precision = precisionListForMetric; - EXCELLON_WRITER* excellonWriter = dynamic_cast( drillWriter.get() ); + + if( excellonWriter == nullptr ) + return CLI::EXIT_CODES::ERR_UNKNOWN; + excellonWriter->SetFormat( aDrillJob->m_drillUnits == JOB_EXPORT_PCB_DRILL::DRILL_UNITS::MILLIMETERS, - zeroFmt, precision.m_Lhs, precision.m_Rhs ); - excellonWriter->SetOptions( aDrillJob->m_excellonMirrorY, aDrillJob->m_excellonMinimalHeader, - offset, aDrillJob->m_excellonCombinePTHNPTH ); + zeroFmt, precision.m_Lhs, precision.m_Rhs ); + excellonWriter->SetOptions( aDrillJob->m_excellonMirrorY, + aDrillJob->m_excellonMinimalHeader, + offset, aDrillJob->m_excellonCombinePTHNPTH ); excellonWriter->SetRouteModeForOvalHoles( aDrillJob->m_excellonOvalDrillRoute ); excellonWriter->SetMapFileFormat( mapFormat ); excellonWriter->CreateDrillandMapFilesSet( aDrillJob->m_outputDir, true, - aDrillJob->m_generateMap, nullptr ); + aDrillJob->m_generateMap, nullptr ); } else if( aDrillJob->m_format == JOB_EXPORT_PCB_DRILL::DRILL_FORMAT::GERBER ) { GERBER_WRITER* gerberWriter = dynamic_cast( drillWriter.get() ); + + if( gerberWriter == nullptr ) + return CLI::EXIT_CODES::ERR_UNKNOWN; + // Set gerber precision: only 5 or 6 digits for mantissa are allowed // (SetFormat() accept 5 or 6, and any other value set the precision to 5) // the integer part precision is always 4, and units always mm @@ -499,7 +513,7 @@ int PCBNEW_JOBS_HANDLER::JobExportDrill( JOB* aJob ) gerberWriter->SetMapFileFormat( mapFormat ); gerberWriter->CreateDrillandMapFilesSet( aDrillJob->m_outputDir, true, - aDrillJob->m_generateMap, nullptr ); + aDrillJob->m_generateMap, nullptr ); } return CLI::EXIT_CODES::OK; @@ -533,7 +547,8 @@ int PCBNEW_JOBS_HANDLER::JobExportPos( JOB* aJob ) aPosJob->m_outputFile = fn.GetFullName(); } - if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::ASCII || aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV ) + if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::ASCII + || aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV ) { FILE* file = nullptr; file = wxFopen( aPosJob->m_outputFile, wxS( "wt" ) ); @@ -549,12 +564,13 @@ int PCBNEW_JOBS_HANDLER::JobExportPos( JOB* aJob ) bool backSide = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK || aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH; - PLACE_FILE_EXPORTER exporter( brd, aPosJob->m_units == JOB_EXPORT_PCB_POS::UNITS::MILLIMETERS, - aPosJob->m_smdOnly, aPosJob->m_excludeFootprintsWithTh, - frontSide, backSide, - aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV, - aPosJob->m_useDrillPlaceFileOrigin, - aPosJob->m_negateBottomX ); + PLACE_FILE_EXPORTER exporter( brd, + aPosJob->m_units == JOB_EXPORT_PCB_POS::UNITS::MILLIMETERS, + aPosJob->m_smdOnly, aPosJob->m_excludeFootprintsWithTh, + frontSide, backSide, + aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV, + aPosJob->m_useDrillPlaceFileOrigin, + aPosJob->m_negateBottomX ); data = exporter.GenPositionData(); fputs( data.c_str(), file ); @@ -722,6 +738,9 @@ int PCBNEW_JOBS_HANDLER::doFpExportSvg( JOB_FP_EXPORT_SVG* aSvgJob, const FOOTPR FOOTPRINT* fp = dynamic_cast( aFootprint->Clone() ); + if( fp == nullptr ) + return CLI::EXIT_CODES::ERR_UNKNOWN; + fp->SetLink( niluuid ); fp->SetFlags( IS_NEW ); fp->SetParent( brd.get() ); @@ -760,4 +779,4 @@ int PCBNEW_JOBS_HANDLER::doFpExportSvg( JOB_FP_EXPORT_SVG* aSvgJob, const FOOTPR return CLI::EXIT_CODES::OK; -} \ No newline at end of file +} diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 38a19a95d2..fa44861010 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -2,7 +2,7 @@ * KiRouter - a push-and-(sometimes-)shove PCB router * * Copyright (C) 2013-2016 CERN - * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * Author: Tomasz Wlostowski * * This program is free software: you can redistribute it and/or modify it @@ -232,6 +232,8 @@ bool PNS_PCBNEW_RULE_RESOLVER::IsNetTieExclusion( const PNS::ITEM* aItem, const VECTOR2I& aCollisionPos, const PNS::ITEM* aCollidingItem ) { + wxCHECK( aItem && aCollidingItem, false ); + std::shared_ptr drcEngine = m_board->GetDesignSettings().m_DRCEngine; BOARD_ITEM* collidingItem = aCollidingItem->Parent(); diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 43c4c4994e..2c230da72d 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -256,6 +256,7 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR obs.m_item = aCandidate; obs.m_head = m_item; obs.m_distFirst = INT_MAX; + obs.m_maxFanoutWidth = 0; m_tab.push_back( obs ); m_matchCount++; @@ -323,6 +324,7 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aLine, int aKindMask, return OPT_OBSTACLE(); OBSTACLE nearest; + nearest.m_head = nullptr; nearest.m_item = nullptr; nearest.m_distFirst = INT_MAX; nearest.m_maxFanoutWidth = 0; diff --git a/qa/unittests/common/test_kicad_stroke_font.cpp b/qa/unittests/common/test_kicad_stroke_font.cpp index 49a1c1d5ce..cdbe15f16a 100644 --- a/qa/unittests/common/test_kicad_stroke_font.cpp +++ b/qa/unittests/common/test_kicad_stroke_font.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 2018, 2023 KiCad Developers, see AUTHORS.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -74,8 +74,11 @@ BOOST_AUTO_TEST_CASE( TabCheck ) VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), EDA_ANGLE::m_Angle0, false, VECTOR2I( 0, 0 ), 0 ); - BOOST_CHECK_MESSAGE( output1.x == output2.x, "Incorrect tab size for \n\t'" << text1.ToStdString() << "' and\n\t'" << text2.ToStdString() << "'" ); + BOOST_CHECK_MESSAGE( output1.x == output2.x, "Incorrect tab size for \n\t'" << + text1.ToStdString() << "' and\n\t'" << text2.ToStdString() << "'" ); } + + delete font; }