diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 9b89ac8b04..d995b14fcb 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -150,11 +150,11 @@ struct remove_pointer template bool IsA(const I *aObject) { - return remove_pointer::type::ClassOf(aObject); + return aObject && remove_pointer::type::ClassOf(aObject); } template -bool IsA(const I& aObject) +bool IsA(const I& aObject) { return remove_pointer::type::ClassOf(&aObject); } diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index b8cdc49950..90f5e2d655 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -222,7 +222,7 @@ private: public: static inline bool ClassOf( const EDA_ITEM* aItem ) { - return PCB_T == aItem->Type(); + return aItem && PCB_T == aItem->Type(); } void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; } diff --git a/pcbnew/class_board_connected_item.h b/pcbnew/class_board_connected_item.h index 7b3f11b511..15dfe31f54 100644 --- a/pcbnew/class_board_connected_item.h +++ b/pcbnew/class_board_connected_item.h @@ -60,9 +60,12 @@ public: static inline bool ClassOf( const EDA_ITEM* aItem ) { + if( aItem == NULL ) + return false; + switch( aItem->Type() ) { - case PCB_PAD_T: + case PCB_PAD_T: case PCB_TRACE_T: case PCB_VIA_T: case PCB_ZONE_AREA_T: diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index fca427d0ad..7b8d5b09c8 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -56,7 +56,7 @@ public: static inline bool ClassOf( const EDA_ITEM* aItem ) { - return PCB_MODULE_EDGE_T == aItem->Type(); + return aItem && PCB_MODULE_EDGE_T == aItem->Type(); } void Copy( EDGE_MODULE* source ); // copy structure diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index d3a7d7ecef..e9595a307f 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -68,7 +68,7 @@ public: static inline bool ClassOf( const EDA_ITEM* aItem ) { - return PCB_MODULE_TEXT_T == aItem->Type(); + return aItem && PCB_MODULE_TEXT_T == aItem->Type(); } diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 258586d3f7..a35b62dcf5 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -82,7 +82,7 @@ class TRACK : public BOARD_CONNECTED_ITEM public: static inline bool ClassOf( const EDA_ITEM* aItem ) { - return PCB_TRACE_T == aItem->Type(); + return aItem && PCB_TRACE_T == aItem->Type(); } BOARD_CONNECTED_ITEM* start; // pointers to a connected item (pad or track) @@ -382,7 +382,7 @@ public: static inline bool ClassOf( const EDA_ITEM *aItem ) { - return PCB_VIA_T == aItem->Type(); + return aItem && PCB_VIA_T == aItem->Type(); } // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 5842a921ce..fa5dbacf73 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -62,6 +62,7 @@ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC ) { PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Panel->GetParent(); BOARD* pcb = frame->GetBoard(); + TRACK* track = dyn_cast( frame->GetCurItem() ); if( track )