Browse Source

Formatting and iterator safety.

6.0.7
Jeff Young 4 years ago
parent
commit
935a307674
  1. 25
      eeschema/sch_sheet.cpp

25
eeschema/sch_sheet.cpp

@ -48,7 +48,7 @@ const wxString SCH_SHEET::GetDefaultFieldName( int aFieldNdx )
static void* locale = nullptr;
static wxString sheetnameDefault;
static wxString sheetfilenameDefault;
static wxString fieldDefault;
static wxString userFieldDefault;
// Fetching translations can take a surprising amount of time when loading libraries,
// so only do it when necessary.
@ -56,7 +56,7 @@ const wxString SCH_SHEET::GetDefaultFieldName( int aFieldNdx )
{
sheetnameDefault = _( "Sheet name" );
sheetfilenameDefault = _( "Sheet file" );
fieldDefault = _( "Field%d" );
userFieldDefault = _( "Field%d" );
locale = Pgm().GetLocale();
}
@ -65,7 +65,7 @@ const wxString SCH_SHEET::GetDefaultFieldName( int aFieldNdx )
{
case SHEETNAME: return sheetnameDefault;
case SHEETFILENAME: return sheetfilenameDefault;
default: return wxString::Format( fieldDefault, aFieldNdx );
default: return wxString::Format( userFieldDefault, aFieldNdx );
}
}
@ -375,7 +375,8 @@ bool SCH_SHEET::HasUndefinedPins() const
{
/* Search the schematic for a hierarchical label corresponding to this sheet label. */
const SCH_HIERLABEL* HLabel = nullptr;
for( auto aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
{
if( !pin->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) )
{
@ -470,26 +471,26 @@ int SCH_SHEET::GetMinHeight( bool aFromTop ) const
void SCH_SHEET::CleanupSheet()
{
auto i = m_pins.begin();
std::vector<SCH_SHEET_PIN*> pins = m_pins;
m_pins.clear();
while( i != m_pins.end() )
for( SCH_SHEET_PIN* pin : pins )
{
/* Search the schematic for a hierarchical label corresponding to this sheet label. */
const SCH_HIERLABEL* HLabel = nullptr;
for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
{
if( (*i)->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) == 0 )
if( pin->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) == 0 )
{
HLabel = static_cast<SCH_HIERLABEL*>( aItem );
break;
}
}
if( HLabel == nullptr ) // Hlabel not found: delete sheet label.
i = m_pins.erase( i );
else
++i;
if( HLabel )
m_pins.push_back( pin );
}
}
@ -646,7 +647,7 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
}
}
for( auto aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
{
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
SCH_SCREEN* screen = sheet->m_screen;

Loading…
Cancel
Save