Commit f31f92e4 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Fixes the bug that causes pcbnew crash, when there are multiple net classes...

Fixes the bug that causes pcbnew crash, when there are multiple net classes and the plot dialog was opened.
Changed NETCLASS* to boost::shared_ptr<NETCLASS>.
parent f49e9a28
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -105,7 +105,7 @@ public:
     * Function GetDefault
     * Function GetDefault
     * @return the default netclass.
     * @return the default netclass.
     */
     */
    inline NETCLASS* GetDefault() const
    inline NETCLASSPTR GetDefault() const
    {
    {
        return m_NetClasses.GetDefault();
        return m_NetClasses.GetDefault();
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -201,7 +201,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
    LAYER_MSK layerMask;
    LAYER_MSK layerMask;


    // use the default NETCLASS?
    // use the default NETCLASS?
    NETCLASS* nc = aPcb->GetDesignSettings().GetDefault();
    NETCLASSPTR nc = aPcb->GetDesignSettings().GetDefault();


    int       trackWidth = nc->GetTrackWidth();
    int       trackWidth = nc->GetTrackWidth();
    int       clearance  = nc->GetClearance();
    int       clearance  = nc->GetClearance();
+1 −1
Original line number Original line Diff line number Diff line
@@ -91,7 +91,7 @@ BOARD::BOARD() :
            m_Layer[layer].m_Type = LT_UNDEFINED;
            m_Layer[layer].m_Type = LT_UNDEFINED;
    }
    }


    NETCLASS* defaultClass = m_designSettings.GetDefault();
    NETCLASSPTR defaultClass = m_designSettings.GetDefault();
    defaultClass->SetDescription( _( "This is the default net class." ) );
    defaultClass->SetDescription( _( "This is the default net class." ) );


    // Initialize default values in default netclass.
    // Initialize default values in default netclass.
+6 −8
Original line number Original line Diff line number Diff line
@@ -89,7 +89,7 @@ const wxString& BOARD_CONNECTED_ITEM::GetShortNetname() const


int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{
{
    NETCLASS*   myclass  = GetNetClass();
    NETCLASSPTR myclass = GetNetClass();


    // DO NOT use wxASSERT, because GetClearance is called inside an OnPaint event
    // DO NOT use wxASSERT, because GetClearance is called inside an OnPaint event
    // and a call to wxASSERT can crash the application.
    // and a call to wxASSERT can crash the application.
@@ -116,7 +116,7 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
}
}




NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
NETCLASSPTR BOARD_CONNECTED_ITEM::GetNetClass() const
{
{
    // It is important that this be implemented without any sequential searching.
    // It is important that this be implemented without any sequential searching.
    // Simple array lookups should be fine, performance-wise.
    // Simple array lookups should be fine, performance-wise.
@@ -128,10 +128,11 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
    if( board == NULL )     // Should not occur
    if( board == NULL )     // Should not occur
    {
    {
        DBG(printf( "%s: NULL board,type %d", __func__, Type() );)
        DBG(printf( "%s: NULL board,type %d", __func__, Type() );)
        return NULL;

        return NETCLASSPTR();
    }
    }


    NETCLASS*       netclass = NULL;
    NETCLASSPTR     netclass;
    NETINFO_ITEM*   net = board->FindNet( GetNetCode() );
    NETINFO_ITEM*   net = board->FindNet( GetNetCode() );


    if( net )
    if( net )
@@ -151,15 +152,12 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
wxString BOARD_CONNECTED_ITEM::GetNetClassName() const
wxString BOARD_CONNECTED_ITEM::GetNetClassName() const
{
{
    wxString    name;
    wxString    name;
    NETCLASS*   myclass = GetNetClass();
    NETCLASSPTR myclass = GetNetClass();


    if( myclass )
    if( myclass )
        name = myclass->GetName();
        name = myclass->GetName();
    else
    else
    {
        BOARD*  board = GetBoard();
        name = NETCLASS::Default;
        name = NETCLASS::Default;
    }


    return name;
    return name;
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -142,7 +142,7 @@ public:
      * Function GetNetClass
      * Function GetNetClass
      * returns the NETCLASS for this item.
      * returns the NETCLASS for this item.
      */
      */
     NETCLASS* GetNetClass() const;
     boost::shared_ptr<NETCLASS> GetNetClass() const;


    /**
    /**
     * Function GetNetClassName
     * Function GetNetClassName
Loading