diff --git a/common/cli/command_export_pcb_svg.cpp b/common/cli/command_export_pcb_svg.cpp index 3c055a4712..8cfae9ef01 100644 --- a/common/cli/command_export_pcb_svg.cpp +++ b/common/cli/command_export_pcb_svg.cpp @@ -78,6 +78,7 @@ int CLI::EXPORT_PCB_SVG_COMMAND::Perform( KIWAY& aKiway ) const if( !wxFile::Exists( svgJob->m_filename ) ) { wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) ); + delete svgJob; return EXIT_CODES::ERR_INVALID_INPUT_FILE; } @@ -89,5 +90,7 @@ int CLI::EXPORT_PCB_SVG_COMMAND::Perform( KIWAY& aKiway ) const int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob ); + delete svgJob; + return exitCode; -} \ No newline at end of file +} diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 2464f945c0..8a6bd7779a 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -446,6 +446,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) void SCH_LABEL_BASE::GetIntersheetRefs( std::vector>* pages ) { + wxCHECK( pages, /* void */ ); + if( Schematic() ) { auto it = Schematic()->GetPageRefsMap().find( GetText() ); diff --git a/eeschema/sim/kibis/kibis.h b/eeschema/sim/kibis/kibis.h index 72ec765abf..88ae4290fd 100644 --- a/eeschema/sim/kibis/kibis.h +++ b/eeschema/sim/kibis/kibis.h @@ -159,7 +159,7 @@ public: IBIS_CORNER m_Cpin = IBIS_CORNER::TYP; IBIS_CORNER m_Ccomp = IBIS_CORNER::TYP; IBIS_CORNER m_supply = IBIS_CORNER::TYP; - KIBIS_WAVEFORM* m_waveform; + KIBIS_WAVEFORM* m_waveform = nullptr; KIBIS_ACCURACY m_accuracy = KIBIS_ACCURACY::LEVEL_2; void SetCornerFromString( IBIS_CORNER& aCorner, std::string aString ); diff --git a/eeschema/sim/sim_model_kibis.h b/eeschema/sim/sim_model_kibis.h index 48b3475f6c..97f5d6139d 100644 --- a/eeschema/sim/sim_model_kibis.h +++ b/eeschema/sim/sim_model_kibis.h @@ -81,7 +81,10 @@ public: } - const PARAM& GetParam( unsigned aParamIndex ) const override { return m_params.at( aParamIndex ); }; + const PARAM& GetParam( unsigned aParamIndex ) const override + { + return m_params.at( aParamIndex ); + }; /** @brief update the list of available models based on the pin number. * */ @@ -93,8 +96,10 @@ public: bool CanDifferential() { return m_enableDiff; }; bool m_enableDiff; - void ReadDataSchFields( unsigned aSymbolPinCount, const std::vector* aFields ) override; - void ReadDataLibFields( unsigned aSymbolPinCount, const std::vector* aFields ) override; + void ReadDataSchFields( unsigned aSymbolPinCount, + const std::vector* aFields ) override; + void ReadDataLibFields( unsigned aSymbolPinCount, + const std::vector* aFields ) override; protected: void CreatePins( unsigned aSymbolPinCount ) override; diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index c3cd519199..3ef1d489b3 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2077,8 +2077,11 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) if( SCH_LABEL_BASE* label = dynamic_cast( item ) ) bbox.Inflate( -label->GetLabelBoxExpansion() ); + EDA_TEXT* textItem = dynamic_cast( item ); + wxCHECK(textItem, 0 ); + // Careful: GetTextMargin() is dependent on font size... - new_textbox->SetTextSize( dynamic_cast( item )->GetTextSize() ); + new_textbox->SetTextSize( textItem->GetTextSize() ); int margin = new_textbox->GetTextMargin(); bbox.Inflate( margin ); diff --git a/pcbnew/drc/drc_test_provider_solder_mask.cpp b/pcbnew/drc/drc_test_provider_solder_mask.cpp index 597ba29c4b..5189704362 100644 --- a/pcbnew/drc/drc_test_provider_solder_mask.cpp +++ b/pcbnew/drc/drc_test_provider_solder_mask.cpp @@ -331,6 +331,7 @@ bool isMaskAperture( BOARD_ITEM* aItem ) return maskLayers.count() > 0 && otherLayers.count() == 0; } + bool DRC_TEST_PROVIDER_SOLDER_MASK::checkMaskAperture( BOARD_ITEM* aMaskItem, BOARD_ITEM* aTestItem, PCB_LAYER_ID aTestLayer, int aTestNet, BOARD_ITEM** aCollidingItem ) @@ -373,7 +374,9 @@ bool DRC_TEST_PROVIDER_SOLDER_MASK::checkItemMask( BOARD_ITEM* aMaskItem, int aT { FOOTPRINT* fp = static_cast( aMaskItem->GetParentFootprint() ); - if( fp && ( fp->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES ) > 0 ) + wxCHECK( fp, false ); + + if( ( fp->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES ) > 0 ) { // If we're allowing bridges then we're allowing bridges. Nothing to check. return false; diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 19fffca124..1715b5e931 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -155,6 +155,8 @@ public: void FOOTPRINT_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem, FOOTPRINT* aFootprint ) { + wxCHECK( aFootprint, /* void */ ); + BASIC_FOOTPRINT_INFO footprintInfo( aFootprint ); if( aTreeItem.IsOk() ) // Can be not found in tree if the current footprint is imported diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index bb1a6874b1..fafaf6d394 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -2163,8 +2163,12 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, std::optional aStartingPoint ) { + wxCHECK( aGraphic, false ); + PCB_SHAPE*& graphic = *aGraphic; + wxCHECK( graphic, false ); + if( m_layer != m_frame->GetActiveLayer() ) { m_layer = m_frame->GetActiveLayer(); diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index 45f7bd8013..d5eaf13842 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -264,8 +264,8 @@ VECTOR2I PCB_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& a //Respect limits of coordinates representation BOX2I bb; - bb.SetOrigin( GetClampedCoords( VECTOR2D( aOrigin ) - snapRange / 2 ) ); - bb.SetEnd( GetClampedCoords( VECTOR2D( aOrigin ) + snapRange / 2 ) ); + bb.SetOrigin( GetClampedCoords( VECTOR2D( aOrigin ) - snapRange / 2.0 ) ); + bb.SetEnd( GetClampedCoords( VECTOR2D( aOrigin ) + snapRange / 2.0 ) ); clearAnchors(); diff --git a/qa/unittests/pcbnew/test_libeval_compiler.cpp b/qa/unittests/pcbnew/test_libeval_compiler.cpp index 8bdb7a02d6..eea7c96d23 100644 --- a/qa/unittests/pcbnew/test_libeval_compiler.cpp +++ b/qa/unittests/pcbnew/test_libeval_compiler.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 2019-2022 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 @@ -77,7 +77,8 @@ const static std::vector introspectionExpressions = { { "A.Width > B.Width", false, VAL( 0.0 ) }, { "A.Width + B.Width", false, VAL( pcbIUScale.MilsToIU(10) + pcbIUScale.MilsToIU(20) ) }, { "A.Netclass", false, VAL( "HV" ) }, - { "(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false, VAL( 1.0 ) }, + { "(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false, + VAL( 1.0 ) }, { "A.Netclass + 1.0", false, VAL( 1.0 ) }, { "A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'", false, VAL( 1.0 ) }, { "(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')", false, VAL( 1.0 ) }, @@ -85,7 +86,7 @@ const static std::vector introspectionExpressions = { }; -static bool testEvalExpr( const wxString& expr, LIBEVAL::VALUE expectedResult, +static bool testEvalExpr( const wxString& expr, const LIBEVAL::VALUE& expectedResult, bool expectError = false, BOARD_ITEM* itemA = nullptr, BOARD_ITEM* itemB = nullptr ) { @@ -123,7 +124,6 @@ static bool testEvalExpr( const wxString& expr, LIBEVAL::VALUE expectedResult, ok = ( result.EqualTo( &context, &expectedResult ) ); } - if( expectedResult.GetType() == LIBEVAL::VT_NUMERIC ) { BOOST_CHECK_EQUAL( result.AsDouble(), expectedResult.AsDouble() ); @@ -133,10 +133,10 @@ static bool testEvalExpr( const wxString& expr, LIBEVAL::VALUE expectedResult, BOOST_CHECK_EQUAL( result.AsString(), expectedResult.AsString() ); } - return ok; } + BOOST_AUTO_TEST_CASE( SimpleExpressions ) { for( const auto& expr : simpleExpressions ) @@ -145,6 +145,7 @@ BOOST_AUTO_TEST_CASE( SimpleExpressions ) } } + BOOST_AUTO_TEST_CASE( IntrospectedProperties ) { PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();