diff --git a/pcbnew/connectivity/connectivity_data.cpp b/pcbnew/connectivity/connectivity_data.cpp index 0df5490e48..390c8cf67d 100644 --- a/pcbnew/connectivity/connectivity_data.cpp +++ b/pcbnew/connectivity/connectivity_data.cpp @@ -1077,3 +1077,10 @@ const std::vector CONNECTIVITY_DATA::GetRatsnestForComponent( FOOTPRINT } +const NET_SETTINGS* CONNECTIVITY_DATA::GetNetSettings() const +{ + if( std::shared_ptr netSettings = m_netSettings.lock() ) + return netSettings.get(); + else + return nullptr; +} diff --git a/pcbnew/connectivity/connectivity_data.h b/pcbnew/connectivity/connectivity_data.h index 0cfc9d4624..4b327d70cb 100644 --- a/pcbnew/connectivity/connectivity_data.h +++ b/pcbnew/connectivity/connectivity_data.h @@ -271,7 +271,7 @@ public: void SetProgressReporter( PROGRESS_REPORTER* aReporter ); - const NET_SETTINGS* GetNetSettings() const { return m_netSettings.get(); } + const NET_SETTINGS* GetNetSettings() const; bool HasNetNameForNetCode( int nc ) const { return m_netcodeMap.count( nc ) > 0; } const wxString& GetNetNameForNetCode( int nc ) const { return m_netcodeMap.at( nc ); } @@ -316,7 +316,7 @@ private: PROGRESS_REPORTER* m_progressReporter; /// @brief Used to get netclass data when drawing ratsnests - std::shared_ptr m_netSettings; + std::weak_ptr m_netSettings; /// @brief Used to map netcode to net name std::map m_netcodeMap; diff --git a/pcbnew/ratsnest/ratsnest_view_item.cpp b/pcbnew/ratsnest/ratsnest_view_item.cpp index 2a6e02f004..25947a7fab 100644 --- a/pcbnew/ratsnest/ratsnest_view_item.cpp +++ b/pcbnew/ratsnest/ratsnest_view_item.cpp @@ -132,7 +132,7 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const { const wxString& netName = m_data->GetNetNameForNetCode( l.netCode ); - if( netSettings->HasEffectiveNetClass( netName ) ) + if( netSettings && netSettings->HasEffectiveNetClass( netName ) ) nc = netSettings->GetCachedEffectiveNetClass( netName ).get(); } @@ -189,7 +189,7 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const { const wxString& netName = m_data->GetNetNameForNetCode( i ); - if( netSettings->HasEffectiveNetClass( netName ) ) + if( netSettings && netSettings->HasEffectiveNetClass( netName ) ) nc = netSettings->GetCachedEffectiveNetClass( netName ).get(); } diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 01e216e455..12680bb08c 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1749,7 +1749,7 @@ void PNS_KICAD_IFACE::DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET { const wxString& netName = connectivity->GetNetNameForNetCode( netCode ); - if( netSettings->HasEffectiveNetClass( netName ) ) + if( netSettings && netSettings->HasEffectiveNetClass( netName ) ) nc = netSettings->GetCachedEffectiveNetClass( netName ).get(); }