Make sure footprint chooser has correct board.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20669
This commit is contained in:
Jeff Young 2025-04-16 17:11:59 +01:00
parent 1c8e20b61f
commit 6bc9653029
3 changed files with 18 additions and 13 deletions

View File

@ -29,6 +29,7 @@
#include <gal/color4d.h> #include <gal/color4d.h>
class FOOTPRINT_PREVIEW_PANEL_BASE; class FOOTPRINT_PREVIEW_PANEL_BASE;
class BOARD;
class FOOTPRINT; class FOOTPRINT;
class KIWAY; class KIWAY;
class TOOL_DISPATCHER; class TOOL_DISPATCHER;
@ -147,6 +148,8 @@ public:
*/ */
virtual EDA_DRAW_PANEL_GAL* GetCanvas() = 0; virtual EDA_DRAW_PANEL_GAL* GetCanvas() = 0;
virtual BOARD* GetBoard() = 0;
/** /**
* Get the colors to use in a preview widget to match the preview panel. * Get the colors to use in a preview widget to match the preview panel.
*/ */

View File

@ -128,7 +128,7 @@ FOOTPRINT_CHOOSER_FRAME::FOOTPRINT_CHOOSER_FRAME( KIWAY* aKiway, wxWindow* aPare
frameSizer->Add( m_chooserPanel, 1, wxEXPAND ); frameSizer->Add( m_chooserPanel, 1, wxEXPAND );
SetCanvas( m_chooserPanel->GetViewerPanel()->GetPreviewPanel()->GetCanvas() ); SetCanvas( m_chooserPanel->GetViewerPanel()->GetPreviewPanel()->GetCanvas() );
SetBoard( new BOARD() ); SetBoard( m_chooserPanel->GetViewerPanel()->GetPreviewPanel()->GetBoard() );
// This board will only be used to hold a footprint for viewing // This board will only be used to hold a footprint for viewing
GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER );
@ -236,6 +236,9 @@ FOOTPRINT_CHOOSER_FRAME::~FOOTPRINT_CHOOSER_FRAME()
m_preview3DCanvas->Show(); m_preview3DCanvas->Show();
m_preview3DCanvas->OnCloseWindow( dummy ); m_preview3DCanvas->OnCloseWindow( dummy );
// Disconnect board, which is owned by FOOTPRINT_PREVIEW_PANEL.
m_pcb = nullptr;
// Disconnect Events // Disconnect Events
m_grButton3DView->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, m_grButton3DView->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::on3DviewReq ), wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::on3DviewReq ),
@ -302,8 +305,7 @@ void FOOTPRINT_CHOOSER_FRAME::Show3DViewerFrame()
} }
void FOOTPRINT_CHOOSER_FRAME::Update3DView( bool aMarkDirty, void FOOTPRINT_CHOOSER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
bool aRefresh, const wxString* aTitle )
{ {
LIB_ID fpID = m_chooserPanel->GetSelectedLibId(); LIB_ID fpID = m_chooserPanel->GetSelectedLibId();
wxString footprintName; wxString footprintName;

View File

@ -54,23 +54,23 @@ public:
virtual ~FOOTPRINT_PREVIEW_PANEL( ); virtual ~FOOTPRINT_PREVIEW_PANEL( );
virtual void SetUserUnits( EDA_UNITS aUnits ) override { m_userUnits = aUnits; } void SetUserUnits( EDA_UNITS aUnits ) override { m_userUnits = aUnits; }
virtual void SetPinFunctions( const std::map<wxString, wxString>& aPinFunctions ) override void SetPinFunctions( const std::map<wxString, wxString>& aPinFunctions ) override
{ {
m_pinFunctions = aPinFunctions; m_pinFunctions = aPinFunctions;
} }
virtual bool DisplayFootprint( const LIB_ID& aFPID ) override; bool DisplayFootprint( const LIB_ID& aFPID ) override;
virtual void DisplayFootprints( std::shared_ptr<FOOTPRINT> aFootprintA, void DisplayFootprints( std::shared_ptr<FOOTPRINT> aFootprintA,
std::shared_ptr<FOOTPRINT> aFootprintB ) override; std::shared_ptr<FOOTPRINT> aFootprintB ) override;
virtual const KIGFX::COLOR4D& GetBackgroundColor() const override; const KIGFX::COLOR4D& GetBackgroundColor() const override;
virtual const KIGFX::COLOR4D& GetForegroundColor() const override; const KIGFX::COLOR4D& GetForegroundColor() const override;
virtual EDA_DRAW_PANEL_GAL* GetCanvas() override { return this; }; EDA_DRAW_PANEL_GAL* GetCanvas() override { return this; };
BOARD* GetBoard() { return m_dummyBoard.get(); } BOARD* GetBoard() override { return m_dummyBoard.get(); }
virtual void RefreshAll() override; void RefreshAll() override;
static FOOTPRINT_PREVIEW_PANEL* New( KIWAY* aKiway, wxWindow* aParent, static FOOTPRINT_PREVIEW_PANEL* New( KIWAY* aKiway, wxWindow* aParent,
UNITS_PROVIDER* aUnitsProvider ); UNITS_PROVIDER* aUnitsProvider );