Clang got cranky on the emplace_back call.

This commit is contained in:
Jeff Young 2025-09-02 12:17:07 +01:00
parent 1e272ca21b
commit 6a171e11fb
2 changed files with 21 additions and 17 deletions

View File

@ -1,7 +1,6 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2023 <author>
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -43,7 +42,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn( const wxString& aFieldName, c
if( GetFieldNameCol( aFieldName ) != -1 ) if( GetFieldNameCol( aFieldName ) != -1 )
return; return;
m_cols.emplace_back( aFieldName, aLabel, aAddedByUser, false, false, aIsCheckbox ); m_cols.push_back( { aFieldName, aLabel, aAddedByUser, false, false, aIsCheckbox } );
for( LIB_SYMBOL* symbol : m_symbolsList ) for( LIB_SYMBOL* symbol : m_symbolsList )
updateDataStoreSymbolField( symbol, aFieldName ); updateDataStoreSymbolField( symbol, aFieldName );
@ -124,7 +123,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::RenameColumn( int aCol, const wxString&
} }
int LIB_FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldNameCol( wxString aFieldName ) int LIB_FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldNameCol( const wxString& aFieldName )
{ {
for( size_t i = 0; i < m_cols.size(); i++ ) for( size_t i = 0; i < m_cols.size(); i++ )
{ {
@ -372,6 +371,7 @@ wxGridCellAttr* LIB_FIELDS_EDITOR_GRID_DATA_MODEL::GetAttr( int aRow, int aCol,
if( cellModified ) if( cellModified )
{ {
wxFont font; wxFont font;
if( attr->HasFont() ) if( attr->HasFont() )
{ {
font = attr->GetFont(); font = attr->GetFont();
@ -476,7 +476,8 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::createActualDerivedSymbol( const LIB_SYM
const_cast<KIID&>( newSymbol->m_Uuid ) = aNewSymbolUuid; const_cast<KIID&>( newSymbol->m_Uuid ) = aNewSymbolUuid;
m_symbolsList.push_back( newSymbol ); m_symbolsList.push_back( newSymbol );
wxLogTrace( traceLibFieldTable, "createActualDerivedSymbol: Added new symbol to list, size now: %zu", m_symbolsList.size() ); wxLogTrace( traceLibFieldTable, "createActualDerivedSymbol: Added new symbol to list, size now: %zu",
m_symbolsList.size() );
// Initialize field data for the new symbol in the data store // Initialize field data for the new symbol in the data store
for( const auto& col : m_cols ) for( const auto& col : m_cols )
@ -574,7 +575,7 @@ bool LIB_FIELDS_EDITOR_GRID_DATA_MODEL::cmp( const LIB_DATA_MODEL_ROW&
// N.B. To meet the iterator sort conditions, we cannot simply invert the truth // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
// to get the opposite sort. i.e. ~(a<b) != (a>b) // to get the opposite sort. i.e. ~(a<b) != (a>b)
auto local_cmp = auto local_cmp =
[ ascending ]( const auto a, const auto b ) [ ascending ]( const wxString& a, const wxString& b )
{ {
if( ascending ) if( ascending )
return a < b; return a < b;
@ -726,7 +727,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows()
// the editor. // the editor.
static_cast<WX_GRID*>( GetView() )->CommitPendingChanges( true ); static_cast<WX_GRID*>( GetView() )->CommitPendingChanges( true );
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, m_rows.size() ); wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, (int) m_rows.size() );
GetView()->ProcessTableMessage( msg ); GetView()->ProcessTableMessage( msg );
} }
@ -772,7 +773,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows()
if( GetView() ) if( GetView() )
{ {
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_rows.size() ); wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, (int) m_rows.size() );
GetView()->ProcessTableMessage( msg ); GetView()->ProcessTableMessage( msg );
} }
@ -805,7 +806,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ExpandRow( int aRow )
m_rows[aRow].m_Flag = GROUP_EXPANDED; m_rows[aRow].m_Flag = GROUP_EXPANDED;
m_rows.insert( m_rows.begin() + aRow + 1, children.begin(), children.end() ); m_rows.insert( m_rows.begin() + aRow + 1, children.begin(), children.end() );
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, aRow, children.size() ); wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, aRow, (int) children.size() );
GetView()->ProcessTableMessage( msg ); GetView()->ProcessTableMessage( msg );
} }
@ -864,8 +865,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ExpandAfterSort()
} }
void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData( void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData( std::function<void( LIB_SYMBOL* )> symbolChangeHandler,
std::function<void( LIB_SYMBOL* )> symbolChangeHandler,
std::function<void()> postApplyHandler ) std::function<void()> postApplyHandler )
{ {
for( LIB_SYMBOL* symbol : m_symbolsList ) for( LIB_SYMBOL* symbol : m_symbolsList )
@ -1011,9 +1011,11 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(
// If that exists, try incrementing the number // If that exists, try incrementing the number
int variant = 2; int variant = 2;
bool nameExists = true; bool nameExists = true;
while( nameExists && variant < 100 ) while( nameExists && variant < 100 )
{ {
nameExists = false; nameExists = false;
for( const LIB_SYMBOL* sym : m_symbolsList ) for( const LIB_SYMBOL* sym : m_symbolsList )
{ {
if( sym->GetName() == actualDerivedName ) if( sym->GetName() == actualDerivedName )
@ -1022,6 +1024,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(
break; break;
} }
} }
if( nameExists ) if( nameExists )
{ {
actualDerivedName = parentSymbol->GetName() + "_" + wxString::Format( "%d", variant ); actualDerivedName = parentSymbol->GetName() + "_" + wxString::Format( "%d", variant );
@ -1102,6 +1105,7 @@ wxGridCellRenderer* LIB_FIELDS_EDITOR_GRID_DATA_MODEL::getStripedRenderer( int a
return stripedRenderer; return stripedRenderer;
} }
// lib_fields_data_model.cpp - Add the isStripeableField method // lib_fields_data_model.cpp - Add the isStripeableField method
bool LIB_FIELDS_EDITOR_GRID_DATA_MODEL::isStripeableField( int aCol ) bool LIB_FIELDS_EDITOR_GRID_DATA_MODEL::isStripeableField( int aCol )
{ {

View File

@ -166,7 +166,7 @@ public:
return m_cols[aCol].m_fieldName; return m_cols[aCol].m_fieldName;
} }
int GetFieldNameCol( wxString aFieldName ); int GetFieldNameCol( const wxString& aFieldName );
void SetFieldsOrder( const std::vector<wxString>& aNewOrder ); void SetFieldsOrder( const std::vector<wxString>& aNewOrder );