7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 19:43:44 +00:00

Hold weak reference to NET_SETTINGS in CONNECTIVITY_DATA

This commit is contained in:
JamesJCode 2024-08-04 09:03:03 +01:00
parent 3c799875d8
commit 03e388be80
4 changed files with 12 additions and 5 deletions

View File

@ -1077,3 +1077,10 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForComponent( FOOTPRINT
}
const NET_SETTINGS* CONNECTIVITY_DATA::GetNetSettings() const
{
if( std::shared_ptr<NET_SETTINGS> netSettings = m_netSettings.lock() )
return netSettings.get();
else
return nullptr;
}

View File

@ -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<NET_SETTINGS> m_netSettings;
std::weak_ptr<NET_SETTINGS> m_netSettings;
/// @brief Used to map netcode to net name
std::map<int, wxString> m_netcodeMap;

View File

@ -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();
}

View File

@ -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();
}