Commit 52d2e7eb authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Fix a bug in ClassOf which crashes Pcbnew when its argument is NULL. It fixes bug #1329364.

parent bb79ec84
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ struct remove_pointer<T*>
template <class T, class I>
bool IsA(const I *aObject)
{
    return remove_pointer<T>::type::ClassOf(aObject);
    return aObject && remove_pointer<T>::type::ClassOf(aObject);
}

template <class T, class I>
+1 −1
Original line number Diff line number Diff line
@@ -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; }
+4 −1
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@ public:

    static inline bool ClassOf( const EDA_ITEM* aItem )
    {
        if( aItem == NULL )
            return false;

        switch( aItem->Type() )
        {
        case PCB_PAD_T:
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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();
    }


Loading