mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
Coverity tweaks.
This commit is contained in:
parent
59caea4344
commit
325570eeec
@ -48,12 +48,8 @@ public:
|
||||
const wxString& GetBoardFile() const { return m_boardFile; }
|
||||
void SetBoardFile( const wxString& aFile ) { m_boardFile = aFile; }
|
||||
|
||||
void SetFields( nlohmann::ordered_map<wxString, wxString>& aFields )
|
||||
{
|
||||
m_fields = std::move( aFields );
|
||||
}
|
||||
|
||||
const nlohmann::ordered_map<wxString, wxString>& GetFields() const { return m_fields; }
|
||||
nlohmann::ordered_map<wxString, wxString>& GetFields() { return m_fields; }
|
||||
|
||||
DESIGN_BLOCK() = default;
|
||||
|
||||
|
@ -325,8 +325,6 @@ DESIGN_BLOCK* DESIGN_BLOCK_IO::DesignBlockLoad( const wxString& aLibraryPath,
|
||||
if( dbMetadata.contains( "keywords" ) )
|
||||
newDB->SetKeywords( dbMetadata["keywords"] );
|
||||
|
||||
nlohmann::ordered_map<wxString, wxString> fields;
|
||||
|
||||
// Read the "fields" object from the JSON
|
||||
if( dbMetadata.contains( "fields" ) )
|
||||
{
|
||||
@ -335,10 +333,8 @@ DESIGN_BLOCK* DESIGN_BLOCK_IO::DesignBlockLoad( const wxString& aLibraryPath,
|
||||
wxString name = wxString::FromUTF8( item.key() );
|
||||
wxString value = wxString::FromUTF8( item.value().get<std::string>() );
|
||||
|
||||
fields[name] = value;
|
||||
newDB->GetFields()[name] = value;
|
||||
}
|
||||
|
||||
newDB->SetFields( fields );
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
|
@ -194,7 +194,7 @@ bool DIALOG_DESIGN_BLOCK_PROPERTIES::TransferDataFromGrid()
|
||||
if( !m_fieldsGrid->CommitPendingChanges() )
|
||||
return false;
|
||||
|
||||
nlohmann::ordered_map<wxString, wxString> newFields;
|
||||
m_designBlock->GetFields().clear();
|
||||
|
||||
for( int row = 0; row < m_fieldsGrid->GetNumberRows(); row++ )
|
||||
{
|
||||
@ -202,17 +202,15 @@ bool DIALOG_DESIGN_BLOCK_PROPERTIES::TransferDataFromGrid()
|
||||
fieldName.Replace( wxT( "\n" ), wxT( "" ), true ); // strip all newlines
|
||||
fieldName.Replace( wxT( " " ), wxT( " " ), true ); // double space to single
|
||||
|
||||
if( newFields.count( fieldName ) )
|
||||
if( m_designBlock->GetFields().count( fieldName ) )
|
||||
{
|
||||
wxMessageBox( _( "Duplicate fields are not allowed." ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
newFields[fieldName] = m_fieldsGrid->GetCellValue( row, 1 );
|
||||
m_designBlock->GetFields()[fieldName] = m_fieldsGrid->GetCellValue( row, 1 );
|
||||
}
|
||||
|
||||
m_designBlock->SetFields( newFields );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -194,10 +194,13 @@ void DIALOG_CONFIG_EQUFILES::OnRemoveFiles( wxCommandEvent& event )
|
||||
wxArrayInt selections;
|
||||
m_filesListBox->GetSelections( selections );
|
||||
|
||||
std::sort( selections.begin(), selections.end() );
|
||||
if( !selections.empty() )
|
||||
{
|
||||
std::sort( selections.begin(), selections.end() );
|
||||
|
||||
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
|
||||
m_filesListBox->Delete( selections[ii] );
|
||||
for( int ii = (int) selections.GetCount() - 1; ii >= 0; ii-- )
|
||||
m_filesListBox->Delete( selections[ii] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1041,59 +1041,62 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnPageChanging( wxBookCtrlEvent& aEvent )
|
||||
void DIALOG_LIB_SYMBOL_PROPERTIES::OnBtnCreateJumperPinGroup( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxArrayInt selections;
|
||||
int n = m_listAvailablePins->GetSelections( selections );
|
||||
wxCHECK( n > 0, /* void */ );
|
||||
m_listAvailablePins->GetSelections( selections );
|
||||
|
||||
m_listJumperPinGroups->Freeze();
|
||||
m_listAvailablePins->Freeze();
|
||||
|
||||
wxString group;
|
||||
int i = 0;
|
||||
|
||||
for( int idx : selections )
|
||||
if( !selections.empty() )
|
||||
{
|
||||
group << m_listAvailablePins->GetString( idx );
|
||||
m_listJumperPinGroups->Freeze();
|
||||
m_listAvailablePins->Freeze();
|
||||
|
||||
if( ++i < n )
|
||||
group << ", ";
|
||||
wxString group;
|
||||
int i = 0;
|
||||
|
||||
for( int idx : selections )
|
||||
{
|
||||
group << m_listAvailablePins->GetString( idx );
|
||||
|
||||
if( ++i < selections.Count() )
|
||||
group << ", ";
|
||||
}
|
||||
|
||||
for( int idx = (int) selections.size() - 1; idx >= 0; --idx )
|
||||
m_listAvailablePins->Delete( selections[idx] );
|
||||
|
||||
m_listJumperPinGroups->AppendString( group );
|
||||
|
||||
m_listJumperPinGroups->Thaw();
|
||||
m_listAvailablePins->Thaw();
|
||||
}
|
||||
|
||||
for( int idx = selections.size() - 1; idx >= 0; --idx )
|
||||
m_listAvailablePins->Delete( selections[idx] );
|
||||
|
||||
m_listJumperPinGroups->AppendString( group );
|
||||
|
||||
m_listJumperPinGroups->Thaw();
|
||||
m_listAvailablePins->Thaw();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_LIB_SYMBOL_PROPERTIES::OnBtnRemoveJumperPinGroup( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxArrayInt selections;
|
||||
m_listJumperPinGroups->GetSelections( selections );
|
||||
|
||||
if( m_listJumperPinGroups->GetSelections( selections ) <= 0 )
|
||||
return;
|
||||
|
||||
m_listJumperPinGroups->Freeze();
|
||||
m_listAvailablePins->Freeze();
|
||||
|
||||
for( int idx : selections )
|
||||
if( !selections.empty() )
|
||||
{
|
||||
wxStringTokenizer tokenizer( m_listJumperPinGroups->GetString( idx ), ", " );
|
||||
m_listJumperPinGroups->Freeze();
|
||||
m_listAvailablePins->Freeze();
|
||||
|
||||
while( tokenizer.HasMoreTokens() )
|
||||
for( int idx : selections )
|
||||
{
|
||||
if( wxString token = tokenizer.GetNextToken(); !token.IsEmpty() )
|
||||
m_listAvailablePins->AppendString( token );
|
||||
wxStringTokenizer tokenizer( m_listJumperPinGroups->GetString( idx ), ", " );
|
||||
|
||||
while( tokenizer.HasMoreTokens() )
|
||||
{
|
||||
if( wxString token = tokenizer.GetNextToken(); !token.IsEmpty() )
|
||||
m_listAvailablePins->AppendString( token );
|
||||
}
|
||||
}
|
||||
|
||||
for( int idx = (int) selections.size() - 1; idx >= 0; --idx )
|
||||
m_listJumperPinGroups->Delete( selections[idx] );
|
||||
|
||||
m_listJumperPinGroups->Thaw();
|
||||
m_listAvailablePins->Thaw();
|
||||
}
|
||||
|
||||
for( int idx = selections.size() - 1; idx >= 0; --idx )
|
||||
m_listJumperPinGroups->Delete( selections[idx] );
|
||||
|
||||
m_listJumperPinGroups->Thaw();
|
||||
m_listAvailablePins->Thaw();
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,19 +98,14 @@ bool SCH_EDIT_FRAME::SaveSheetAsDesignBlock( const wxString& aLibraryName, SCH_S
|
||||
blk.SetLibId( LIB_ID( aLibraryName, fn.GetName() ) );
|
||||
|
||||
// Copy all fields from the sheet to the design block
|
||||
std::vector<SCH_FIELD>& shFields = aSheetPath.Last()->GetFields();
|
||||
nlohmann::ordered_map<wxString, wxString> dbFields;
|
||||
|
||||
for( SCH_FIELD& f : shFields )
|
||||
for( SCH_FIELD& field : aSheetPath.Last()->GetFields() )
|
||||
{
|
||||
if( f.GetId() == FIELD_T::SHEET_NAME || f.GetId() == FIELD_T::SHEET_FILENAME )
|
||||
if( field.GetId() == FIELD_T::SHEET_NAME || field.GetId() == FIELD_T::SHEET_FILENAME )
|
||||
continue;
|
||||
|
||||
dbFields[f.GetCanonicalName()] = f.GetText();
|
||||
blk.GetFields()[field.GetCanonicalName()] = field.GetText();
|
||||
}
|
||||
|
||||
blk.SetFields( dbFields );
|
||||
|
||||
DIALOG_DESIGN_BLOCK_PROPERTIES dlg( this, &blk );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
@ -191,19 +186,14 @@ bool SCH_EDIT_FRAME::SaveSheetToDesignBlock( const LIB_ID& aLibId, SCH_SHEET_PAT
|
||||
// Copy all fields from the sheet to the design block.
|
||||
// Note: this will overwrite any existing fields in the design block, but
|
||||
// will leave extra fields not in this source sheet alone.
|
||||
std::vector<SCH_FIELD>& shFields = aSheetPath.Last()->GetFields();
|
||||
nlohmann::ordered_map<wxString, wxString> dbFields = blk->GetFields();
|
||||
|
||||
for( SCH_FIELD& f : shFields )
|
||||
for( SCH_FIELD& field : aSheetPath.Last()->GetFields() )
|
||||
{
|
||||
if( f.GetId() == FIELD_T::SHEET_NAME || f.GetId() == FIELD_T::SHEET_FILENAME )
|
||||
if( field.GetId() == FIELD_T::SHEET_NAME || field.GetId() == FIELD_T::SHEET_FILENAME )
|
||||
continue;
|
||||
|
||||
dbFields[f.GetCanonicalName()] = f.GetText();
|
||||
blk->GetFields()[field.GetCanonicalName()] = field.GetText();
|
||||
}
|
||||
|
||||
blk->SetFields( dbFields );
|
||||
|
||||
DIALOG_DESIGN_BLOCK_PROPERTIES dlg( this, blk.get(), true );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
|
@ -39,11 +39,11 @@ extern wxString getElectricalTypeLabel( LABEL_FLAG_SHAPE aType );
|
||||
|
||||
SHEET_SYNCHRONIZATION_MODEL::SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent,
|
||||
SCH_SHEET* aSheet,
|
||||
SCH_SHEET_PATH& aPath ) :
|
||||
const SCH_SHEET_PATH& aPath ) :
|
||||
m_selectedIndex( std::optional<unsigned>() ),
|
||||
m_agent( aAgent ),
|
||||
m_sheet( aSheet ),
|
||||
m_path( std::move( aPath ) )
|
||||
m_path( aPath )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
|
||||
|
||||
SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent, SCH_SHEET* aSheet,
|
||||
SCH_SHEET_PATH& aPath );
|
||||
const SCH_SHEET_PATH& aPath );
|
||||
~SHEET_SYNCHRONIZATION_MODEL() override;
|
||||
|
||||
void GetValueByRow( wxVariant& variant, unsigned row, unsigned col ) const override;
|
||||
|
@ -31,14 +31,18 @@ class thread_pool;
|
||||
class KICAD_SINGLETON
|
||||
{
|
||||
public:
|
||||
KICAD_SINGLETON(){};
|
||||
KICAD_SINGLETON() :
|
||||
m_ThreadPool( nullptr ),
|
||||
m_GLContextManager( nullptr )
|
||||
{};
|
||||
|
||||
~KICAD_SINGLETON();
|
||||
|
||||
|
||||
void Init();
|
||||
|
||||
BS::thread_pool* m_ThreadPool;
|
||||
public:
|
||||
BS::thread_pool* m_ThreadPool;
|
||||
GL_CONTEXT_MANAGER* m_GLContextManager;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user