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
This commit is contained in:
Jeff Young 2023-07-01 11:51:37 +01:00
parent 011a8f29a3
commit 9ff33e5ec6
7 changed files with 26 additions and 16 deletions

View File

@ -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();

View File

@ -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 );

View File

@ -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();
};

View File

@ -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<BOARD_ITEM
int PCB_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
{
PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
BOARD_COMMIT commit( m_toolMgr );
BOARD_COMMIT commit( editFrame );
if( !editFrame )
return 1;

View File

@ -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<ZONE*> toFill;

View File

@ -31,6 +31,7 @@
#include <mutex>
#include <map>
#include <reporter.h>
#include <tools/pcb_tool_base.h>
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.

View File

@ -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<CLEANUP_ITEM> > dryRunItems;
std::vector< std::shared_ptr<CLEANUP_ITEM> > 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<CLEANUP_ITEM> > dryRunItems;
std::vector< std::shared_ptr<CLEANUP_ITEM> > realRunItems;