diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index cb50b55ec4..1f19f7000d 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -512,16 +512,21 @@ std::shared_ptr SCH_ITEM::GetEffectiveNetClass( const SCH_SHEET_PATH* SCHEMATIC* schematic = Schematic(); - if( schematic ) - { - std::shared_ptr& netSettings = schematic->Project().GetProjectFile().m_NetSettings; - SCH_CONNECTION* connection = Connection( aSheet ); + if( !schematic || !schematic->IsValid() ) + return nullNetclass; - if( connection ) - return netSettings->GetEffectiveNetClass( connection->Name() ); - else - return netSettings->GetDefaultNetclass(); - } + std::shared_ptr& netSettings = schematic->Project().GetProjectFile().m_NetSettings; + + if( !netSettings ) + return nullNetclass; + + SCH_CONNECTION* connection = Connection( aSheet ); + + if( connection ) + return netSettings->GetEffectiveNetClass( connection->Name() ); + + if( std::shared_ptr defaultNetclass = netSettings->GetDefaultNetclass() ) + return defaultNetclass; return nullNetclass; }