From 9ff33e5ec6a1813a39722b43ef300bf9dfeb3520 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 Jul 2023 11:51:37 +0100 Subject: [PATCH] Remove BOARD_COMMIT( TOOL_MANAGER ). It initializes both m_isFootprintEditor and m_isBoardEditor to false, causing all sorts of trouble. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15072 --- pcbnew/board_commit.cpp | 8 -------- pcbnew/board_commit.h | 1 - pcbnew/tools/edit_tool.cpp | 4 ++-- pcbnew/tools/pcb_control.cpp | 4 ++-- qa/pcbnew_utils/board_test_utils.cpp | 5 ++++- .../include/pcbnew_utils/board_test_utils.h | 10 ++++++++++ qa/tests/pcbnew/test_tracks_cleaner.cpp | 10 ++++++++-- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 106b47d1be..220dec3b92 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -42,14 +42,6 @@ using namespace std::placeholders; -BOARD_COMMIT::BOARD_COMMIT( TOOL_MANAGER* aToolMgr ) : - m_toolMgr( aToolMgr ), - m_isFootprintEditor( false ), - m_isBoardEditor( false ) -{ -} - - BOARD_COMMIT::BOARD_COMMIT( PCB_TOOL_BASE* aTool ) { m_toolMgr = aTool->GetManager(); diff --git a/pcbnew/board_commit.h b/pcbnew/board_commit.h index e8d5854c49..7f90f1072e 100644 --- a/pcbnew/board_commit.h +++ b/pcbnew/board_commit.h @@ -46,7 +46,6 @@ class TOOL_BASE; class BOARD_COMMIT : public COMMIT { public: - BOARD_COMMIT( TOOL_MANAGER* aToolMgr ); BOARD_COMMIT( EDA_DRAW_FRAME* aFrame ); BOARD_COMMIT( PCB_TOOL_BASE *aTool ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 088303c03c..30a7c8d8e2 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -92,7 +92,7 @@ POSITIONING_TOOLS_MENU::POSITIONING_TOOLS_MENU( TOOL_INTERACTIVE* aTool ) : SetTitle( _( "Positioning Tools" ) ); auto notMovingCondition = - [ this ]( const SELECTION& aSelection ) + []( const SELECTION& aSelection ) { return aSelection.Empty() || !aSelection.Front()->IsMoving(); }; @@ -169,7 +169,7 @@ bool EDIT_TOOL::Init() }; auto notMovingCondition = - [ this ]( const SELECTION& aSelection ) + []( const SELECTION& aSelection ) { return aSelection.Empty() || !aSelection.Front()->IsMoving(); }; diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index ee30cf685d..10f62bab00 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -873,7 +873,7 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) if( isFootprintEditor && ( !board() || !footprint() ) ) return 0; - BOARD_COMMIT commit( m_toolMgr ); + BOARD_COMMIT commit( frame() ); bool cancelled = false; switch( clipItem->Type() ) @@ -1203,7 +1203,7 @@ bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, std::vector( m_frame ); - BOARD_COMMIT commit( m_toolMgr ); + BOARD_COMMIT commit( editFrame ); if( !editFrame ) return 1; diff --git a/qa/pcbnew_utils/board_test_utils.cpp b/qa/pcbnew_utils/board_test_utils.cpp index c3572d3e31..0f821cedf7 100644 --- a/qa/pcbnew_utils/board_test_utils.cpp +++ b/qa/pcbnew_utils/board_test_utils.cpp @@ -109,7 +109,10 @@ void FillZones( BOARD* m_board ) TOOL_MANAGER toolMgr; toolMgr.SetEnvironment( m_board, nullptr, nullptr, nullptr, nullptr ); - BOARD_COMMIT commit( &toolMgr ); + KI_TEST::DUMMY_TOOL* dummyTool = new KI_TEST::DUMMY_TOOL(); + toolMgr.RegisterTool( dummyTool ); + + BOARD_COMMIT commit( dummyTool ); ZONE_FILLER filler( m_board, &commit ); std::vector toFill; diff --git a/qa/pcbnew_utils/include/pcbnew_utils/board_test_utils.h b/qa/pcbnew_utils/include/pcbnew_utils/board_test_utils.h index 1bce2339f3..522624a58d 100644 --- a/qa/pcbnew_utils/include/pcbnew_utils/board_test_utils.h +++ b/qa/pcbnew_utils/include/pcbnew_utils/board_test_utils.h @@ -31,6 +31,7 @@ #include #include #include +#include class BOARD; class BOARD_ITEM; @@ -45,6 +46,15 @@ class SETTINGS_MANAGER; namespace KI_TEST { +class DUMMY_TOOL : public PCB_TOOL_BASE +{ +public: + DUMMY_TOOL() : + PCB_TOOL_BASE( "testframework.dummytool" ) + {}; +}; + + /** * A helper that contains logic to assist in dumping boards to * disk depending on some environment variables. diff --git a/qa/tests/pcbnew/test_tracks_cleaner.cpp b/qa/tests/pcbnew/test_tracks_cleaner.cpp index d1a149ae1a..e6e0f08246 100644 --- a/qa/tests/pcbnew/test_tracks_cleaner.cpp +++ b/qa/tests/pcbnew/test_tracks_cleaner.cpp @@ -83,7 +83,10 @@ BOOST_FIXTURE_TEST_CASE( FailedToCleanRegressionTests, TRACK_CLEANER_TEST_FIXTUR TOOL_MANAGER toolMgr; toolMgr.SetEnvironment( m_board.get(), nullptr, nullptr, nullptr, nullptr ); - BOARD_COMMIT commit( &toolMgr ); + KI_TEST::DUMMY_TOOL* dummyTool = new KI_TEST::DUMMY_TOOL(); + toolMgr.RegisterTool( dummyTool ); + + BOARD_COMMIT commit( dummyTool ); TRACKS_CLEANER cleaner( m_board.get(), commit ); std::vector< std::shared_ptr > dryRunItems; std::vector< std::shared_ptr > realRunItems; @@ -152,7 +155,10 @@ BOOST_FIXTURE_TEST_CASE( TrackCleanerRegressionTests, TRACK_CLEANER_TEST_FIXTURE TOOL_MANAGER toolMgr; toolMgr.SetEnvironment( m_board.get(), nullptr, nullptr, nullptr, nullptr ); - BOARD_COMMIT commit( &toolMgr ); + KI_TEST::DUMMY_TOOL* dummyTool = new KI_TEST::DUMMY_TOOL(); + toolMgr.RegisterTool( dummyTool ); + + BOARD_COMMIT commit( dummyTool ); TRACKS_CLEANER cleaner( m_board.get(), commit ); std::vector< std::shared_ptr > dryRunItems; std::vector< std::shared_ptr > realRunItems;