Browse Source

Hold weak reference to NET_SETTINGS in CONNECTIVITY_DATA

jobs
JamesJCode 1 year ago
parent
commit
03e388be80
  1. 7
      pcbnew/connectivity/connectivity_data.cpp
  2. 4
      pcbnew/connectivity/connectivity_data.h
  3. 4
      pcbnew/ratsnest/ratsnest_view_item.cpp
  4. 2
      pcbnew/router/pns_kicad_iface.cpp

7
pcbnew/connectivity/connectivity_data.cpp

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

4
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<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;

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

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

Loading…
Cancel
Save