diff --git a/include/widgets/footprint_preview_widget.h b/include/widgets/footprint_preview_widget.h index 62a55f3db1..639a90cf6b 100644 --- a/include/widgets/footprint_preview_widget.h +++ b/include/widgets/footprint_preview_widget.h @@ -29,6 +29,7 @@ #include class FOOTPRINT_PREVIEW_PANEL_BASE; +class BOARD; class FOOTPRINT; class KIWAY; class TOOL_DISPATCHER; @@ -147,6 +148,8 @@ public: */ 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. */ diff --git a/pcbnew/footprint_chooser_frame.cpp b/pcbnew/footprint_chooser_frame.cpp index 506903cc9c..6277863cfc 100644 --- a/pcbnew/footprint_chooser_frame.cpp +++ b/pcbnew/footprint_chooser_frame.cpp @@ -128,7 +128,7 @@ FOOTPRINT_CHOOSER_FRAME::FOOTPRINT_CHOOSER_FRAME( KIWAY* aKiway, wxWindow* aPare frameSizer->Add( m_chooserPanel, 1, wxEXPAND ); 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 GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); @@ -236,6 +236,9 @@ FOOTPRINT_CHOOSER_FRAME::~FOOTPRINT_CHOOSER_FRAME() m_preview3DCanvas->Show(); m_preview3DCanvas->OnCloseWindow( dummy ); + // Disconnect board, which is owned by FOOTPRINT_PREVIEW_PANEL. + m_pcb = nullptr; + // Disconnect Events m_grButton3DView->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::on3DviewReq ), @@ -302,8 +305,7 @@ void FOOTPRINT_CHOOSER_FRAME::Show3DViewerFrame() } -void FOOTPRINT_CHOOSER_FRAME::Update3DView( bool aMarkDirty, - bool aRefresh, const wxString* aTitle ) +void FOOTPRINT_CHOOSER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle ) { LIB_ID fpID = m_chooserPanel->GetSelectedLibId(); wxString footprintName; diff --git a/pcbnew/footprint_preview_panel.h b/pcbnew/footprint_preview_panel.h index 4744493600..3cc05ab0e3 100644 --- a/pcbnew/footprint_preview_panel.h +++ b/pcbnew/footprint_preview_panel.h @@ -54,23 +54,23 @@ public: virtual ~FOOTPRINT_PREVIEW_PANEL( ); - virtual void SetUserUnits( EDA_UNITS aUnits ) override { m_userUnits = aUnits; } - virtual void SetPinFunctions( const std::map& aPinFunctions ) override + void SetUserUnits( EDA_UNITS aUnits ) override { m_userUnits = aUnits; } + void SetPinFunctions( const std::map& aPinFunctions ) override { m_pinFunctions = aPinFunctions; } - virtual bool DisplayFootprint( const LIB_ID& aFPID ) override; - virtual void DisplayFootprints( std::shared_ptr aFootprintA, - std::shared_ptr aFootprintB ) override; + bool DisplayFootprint( const LIB_ID& aFPID ) override; + void DisplayFootprints( std::shared_ptr aFootprintA, + std::shared_ptr aFootprintB ) override; - virtual const KIGFX::COLOR4D& GetBackgroundColor() const override; - virtual const KIGFX::COLOR4D& GetForegroundColor() const override; + const KIGFX::COLOR4D& GetBackgroundColor() const override; + const KIGFX::COLOR4D& GetForegroundColor() const override; - virtual EDA_DRAW_PANEL_GAL* GetCanvas() override { return this; }; - BOARD* GetBoard() { return m_dummyBoard.get(); } + EDA_DRAW_PANEL_GAL* GetCanvas() override { return this; }; + BOARD* GetBoard() override { return m_dummyBoard.get(); } - virtual void RefreshAll() override; + void RefreshAll() override; static FOOTPRINT_PREVIEW_PANEL* New( KIWAY* aKiway, wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider );