Fix crash when pasting to view-only frames

Fixes https://gitlab.com/kicad/code/kicad/issues/6233
This commit is contained in:
Seth Hillbrand 2020-10-30 16:33:24 -07:00
parent dcd237e298
commit a551a500bb
3 changed files with 16 additions and 11 deletions

View File

@ -77,7 +77,7 @@ END_EVENT_TABLE()
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aFrameType ) :
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
PCB_BASE_EDIT_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
wxDefaultPosition, wxDefaultSize,
aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
@ -96,13 +96,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
m_wizardName.Empty();
SetBoard( new BOARD() );
// Ensure all layers and items are visible:
GetBoard()->SetVisibleAlls();
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
GetScreen()->m_Center = true; // Center coordinate origins on screen.
// Create the GAL canvas.
// Must be created before calling LoadSettings() that needs a valid GAL canvas
PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
@ -111,6 +104,13 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
EDA_DRAW_PANEL_GAL::GAL_FALLBACK );
SetCanvas( gal_drawPanel );
SetBoard( new BOARD() );
// Ensure all layers and items are visible:
GetBoard()->SetVisibleAlls();
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
GetScreen()->m_Center = true; // Center coordinate origins on screen.
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );

View File

@ -33,6 +33,7 @@
#include <wx/gdicmn.h>
#include <footprint_wizard.h>
#include <pcb_base_edit_frame.h>
class wxSashLayoutWindow;
class wxListBox;
class WX_GRID;
@ -50,7 +51,7 @@ enum WizardParameterColumnNames
/**
* FOOTPRINT_WIZARD_FRAME
*/
class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME
class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_EDIT_FRAME
{
private:
wxPanel* m_parametersPanel; ///< Panel for the page list and parameter grid
@ -217,12 +218,12 @@ private:
void Update3DView( bool aForceReload, const wxString* aTitle ) override;
/*
* Virtual functions, not used here, but needed by PCB_BASE_FRAME
* Virtual functions, not used here, but needed by PCB_BASE_EDIT_FRAME
* (virtual pure functions )
*/
void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO, const wxPoint& ) override {}
void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO, const wxPoint& ) override {}
void OnEditItemRequest( BOARD_ITEM* aItem ) override {}
DECLARE_EVENT_TABLE()
};

View File

@ -630,6 +630,10 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
if( !clipItem )
return 0;
// The viewer frames cannot paste
if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
return 0;
bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
if( clipItem->Type() == PCB_T )