eeschema: Check for proper type before dereference
When bundling a selection, we need to ensure that we have correct types before attempting to dereference. Fixes: lp:1841919 * https://bugs.launchpad.net/kicad/+bug/1841919
This commit is contained in:
parent
c3274e15f2
commit
83b2332f1f
|
@ -78,6 +78,11 @@ public:
|
|||
m_image->SetScale( aScale );
|
||||
}
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_BITMAP_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_BITMAP" );
|
||||
|
|
|
@ -132,6 +132,11 @@ public:
|
|||
|
||||
~SCH_BUS_WIRE_ENTRY() { }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_BUS_WIRE_ENTRY_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_BUS_WIRE_ENTRY" );
|
||||
|
@ -174,6 +179,11 @@ public:
|
|||
|
||||
~SCH_BUS_BUS_ENTRY() { }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_BUS_BUS_ENTRY_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_BUS_BUS_ENTRY" );
|
||||
|
|
|
@ -63,6 +63,11 @@ public:
|
|||
|
||||
~SCH_FIELD();
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_FIELD_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_FIELD" );
|
||||
|
|
|
@ -41,6 +41,11 @@ public:
|
|||
|
||||
~SCH_JUNCTION() { }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_JUNCTION_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_JUNCTION" );
|
||||
|
|
|
@ -57,6 +57,11 @@ public:
|
|||
SCH_LINE* Next() const { return (SCH_LINE*) Pnext; }
|
||||
SCH_LINE* Back() const { return (SCH_LINE*) Pback; }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_LINE_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_LINE" );
|
||||
|
|
|
@ -38,6 +38,11 @@ public:
|
|||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_MARKER_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_MARKER" );
|
||||
|
|
|
@ -46,6 +46,11 @@ public:
|
|||
|
||||
~SCH_NO_CONNECT() { }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_NO_CONNECT_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_NO_CONNECT" );
|
||||
|
|
|
@ -49,6 +49,11 @@ public:
|
|||
|
||||
SCH_PIN& operator=( const SCH_PIN& aPin );
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_PIN_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_PIN" );
|
||||
|
|
|
@ -105,6 +105,11 @@ public:
|
|||
|
||||
DLIST< SCH_ITEM > & GetDrawList() { return m_drawList; }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_SCREEN_T == aItem->Type();
|
||||
}
|
||||
|
||||
virtual wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_SCREEN" );
|
||||
|
|
|
@ -91,6 +91,11 @@ public:
|
|||
|
||||
~SCH_SHEET_PIN() { }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_SHEET_PIN_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_SHEET_PIN" );
|
||||
|
@ -243,6 +248,11 @@ public:
|
|||
|
||||
~SCH_SHEET();
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_SHEET_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_SHEET" );
|
||||
|
|
|
@ -93,6 +93,11 @@ public:
|
|||
|
||||
~SCH_TEXT() { }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_TEXT_T == aItem->Type();
|
||||
}
|
||||
|
||||
virtual wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_TEXT" );
|
||||
|
@ -217,6 +222,11 @@ public:
|
|||
|
||||
~SCH_LABEL() { }
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_LABEL_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_LABEL" );
|
||||
|
@ -258,6 +268,11 @@ public:
|
|||
|
||||
void Print( wxDC* DC, const wxPoint& offset ) override;
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_GLOBAL_LABEL_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_GLOBALLABEL" );
|
||||
|
@ -303,6 +318,11 @@ public:
|
|||
|
||||
void Print( wxDC* DC, const wxPoint& offset ) override;
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && SCH_HIER_LABEL_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_HIERLABEL" );
|
||||
|
|
|
@ -696,12 +696,13 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
|||
view->Query( selectionBox, selectedItems ); // Get the list of selected items
|
||||
|
||||
// Sheet pins aren't in the view; add them by hand
|
||||
for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
|
||||
for( auto& pair : selectedItems )
|
||||
{
|
||||
if( static_cast<EDA_ITEM*>( pair.first )->Type() == SCH_SHEET_T )
|
||||
auto item = dynamic_cast<EDA_ITEM*>( pair.first );
|
||||
|
||||
if( auto sheet = dyn_cast<SCH_SHEET*>( item ) )
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) pair.first;
|
||||
int layer = pair.second;
|
||||
int layer = pair.second;
|
||||
|
||||
for( SCH_SHEET_PIN& pin : sheet->GetPins() )
|
||||
selectedItems.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( &pin, layer ) );
|
||||
|
|
Loading…
Reference in New Issue