7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 09:00:13 +00:00

Another reduction in asserts.

This commit is contained in:
Jeff Young 2024-07-19 22:11:23 +01:00
parent 7cad4f5639
commit b8819b4636
20 changed files with 82 additions and 91 deletions

View File

@ -177,7 +177,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
break;
default:
wxFAIL_MSG( "PlotDrawingSheet(): Unknown drawing sheet item." );
wxFAIL_MSG( wxT( "PlotDrawingSheet(): Unknown drawing sheet item." ) );
break;
}
}

View File

@ -1177,10 +1177,10 @@ void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
{
switch( aNumber )
{
case 0: m_statusLine1->SetLabel( aText ); break;
case 1: m_statusLine2->SetLabel( aText ); break;
case 2: m_statusLine3->SetLabel( aText ); break;
default: wxFAIL_MSG( "Invalid status row number" ); break;
case 0: m_statusLine1->SetLabel( aText ); break;
case 1: m_statusLine2->SetLabel( aText ); break;
case 2: m_statusLine3->SetLabel( aText ); break;
default: wxFAIL_MSG( wxT( "Invalid status row number" ) ); break;
}
}

View File

@ -104,7 +104,7 @@ bool DIALOG_LINE_PROPERTIES::TransferDataToWindow()
else if( style < (int) lineTypeNames.size() )
m_typeCombo->SetSelection( style );
else
wxFAIL_MSG( "Line type not found in the type lookup map" );
wxFAIL_MSG( wxT( "Line type not found in the type lookup map" ) );
}
else
{

View File

@ -143,7 +143,7 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow()
else if( style < (int) lineTypeNames.size() )
m_borderStyleCombo->SetSelection( style );
else
wxFAIL_MSG( "Line type not found in the type lookup map" );
wxFAIL_MSG( wxT( "Line type not found in the type lookup map" ) );
if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) )
{

View File

@ -827,7 +827,8 @@ bool SCH_EDIT_FRAME::saveSchematicFile( SCH_SHEET* aSheet, const wxString& aSave
wxCHECK( screen, false );
// Cannot save to nowhere
wxCHECK( !aSavePath.IsEmpty(), false );
if( aSavePath.IsEmpty() )
return false;
// Construct the name of the file to be saved
schematicFileName = Prj().AbsolutePath( aSavePath );

View File

@ -795,14 +795,15 @@ void LIB_SYMBOL::RemoveDrawItem( SCH_ITEM* aItem )
void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort )
{
wxCHECK( aItem, /* void */ );
if( aItem )
{
aItem->SetParent( this );
aItem->SetParent( this );
m_drawings.push_back( aItem );
m_drawings.push_back( aItem );
if( aSort )
m_drawings.sort();
if( aSort )
m_drawings.sort();
}
}
@ -1791,8 +1792,6 @@ int LIB_SYMBOL::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
const LIB_SYMBOL* tmp = static_cast<const LIB_SYMBOL*>( &aOther );
wxCHECK( tmp, -1 );
return Compare( *tmp, aCompareFlags );
}

View File

@ -52,8 +52,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
{
const SCH_LINE* line = static_cast<const SCH_LINE*>( aItem );
wxCHECK( line, retv );
if( aItem->GetLayer() == LAYER_WIRE )
{
retv.Printf( _( "Wire from %s, %s to %s, %s" ),
@ -80,33 +78,35 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_PIN_T:
{
const SCH_PIN* pin = static_cast<const SCH_PIN*>( aItem );
wxCHECK( pin, retv );
const SYMBOL* symbol = pin->GetParentSymbol();
wxCHECK( symbol, retv );
if( const SYMBOL* symbol = pin->GetParentSymbol() )
{
retv.Printf( _( "Symbol '%s' pin '%s'" ),
symbol->GetRef( &aSheetPath, true ),
UnescapeString( pin->GetNumber() ) );
}
retv.Printf( _( "Symbol '%s' pin '%s'" ), symbol->GetRef( &aSheetPath, true ),
UnescapeString( pin->GetNumber() ) );
break;
}
case SCH_SHEET_PIN_T:
{
const SCH_SHEET_PIN* pin = static_cast<const SCH_SHEET_PIN*>( aItem );
wxCHECK( pin, retv );
SCH_SHEET* sheet = pin->GetParent();
wxCHECK( sheet, retv );
if( SCH_SHEET* sheet = pin->GetParent() )
{
retv.Printf( _( "Sheet '%s' pin '%s'" ),
sheet->GetName(),
UnescapeString( pin->GetText() ) );
}
retv.Printf( _( "Sheet '%s' pin '%s'" ), sheet->GetName(),
UnescapeString( pin->GetText() ) );
break;
}
case SCH_LABEL_T:
{
const SCH_LABEL* label = static_cast<const SCH_LABEL*>( aItem );
wxCHECK( label, retv );
retv.Printf( _( "Label '%s' at %s, %s" ), UnescapeString( label->GetText() ),
retv.Printf( _( "Label '%s' at %s, %s" ),
UnescapeString( label->GetText() ),
aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) );
break;
@ -114,7 +114,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_GLOBAL_LABEL_T:
{
const SCH_GLOBALLABEL* label = static_cast<const SCH_GLOBALLABEL*>( aItem );
wxCHECK( label, retv );
retv.Printf( _( "Global label '%s' at %s, %s" ), UnescapeString( label->GetText() ),
aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
@ -124,7 +123,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_HIER_LABEL_T:
{
const SCH_HIERLABEL* label = static_cast<const SCH_HIERLABEL*>( aItem );
wxCHECK( label, retv );
retv.Printf( _( "Hierarchical label '%s' at %s, %s" ), UnescapeString( label->GetText() ),
aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
@ -134,7 +132,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_JUNCTION_T:
{
const SCH_JUNCTION* junction = static_cast<const SCH_JUNCTION*>( aItem );
wxCHECK( junction, retv );
retv.Printf( _( "Junction at %s, %s" ),
aUnitsProvider->MessageTextFromValue( junction->GetPosition().x ),
@ -144,7 +141,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_NO_CONNECT_T:
{
const SCH_NO_CONNECT* nc = static_cast<const SCH_NO_CONNECT*>( aItem );
wxCHECK( nc, retv );
retv.Printf( _( "No-Connect at %s, %s" ),
aUnitsProvider->MessageTextFromValue( nc->GetPosition().x ),
@ -154,7 +150,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_BUS_WIRE_ENTRY_T:
{
const SCH_BUS_WIRE_ENTRY* entry = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem );
wxCHECK( entry, retv );
retv.Printf( _( "Bus to wire entry from %s, %s to %s, %s" ),
aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
@ -166,7 +161,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_BUS_BUS_ENTRY_T:
{
const SCH_BUS_BUS_ENTRY* entry = static_cast<const SCH_BUS_BUS_ENTRY*>( aItem );
wxCHECK( entry, retv );
retv.Printf( _( "Bus to bus entry from %s, %s to %s, %s" ),
aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
@ -178,7 +172,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
case SCH_DIRECTIVE_LABEL_T:
{
const SCH_DIRECTIVE_LABEL* entry = static_cast<const SCH_DIRECTIVE_LABEL*>( aItem );
wxCHECK( entry, retv );
retv.Printf( _( "Netclass label '%s' at %s, %s" ), UnescapeString( entry->GetText() ),
aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),

View File

@ -444,9 +444,9 @@ void SCH_BASE_FRAME::AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen )
// Null pointers will cause boost::ptr_vector to raise a boost::bad_pointer exception which
// will be unhandled. There is no valid reason to pass an invalid EDA_ITEM pointer to the
// screen append function.
wxCHECK( aItem != nullptr, /* void */ );
wxCHECK( aItem, /* void */ );
auto screen = aScreen;
SCH_SCREEN* screen = aScreen;
if( aScreen == nullptr )
screen = GetScreen();

View File

@ -1121,12 +1121,13 @@ void SCH_EDIT_FRAME::OnModify()
{
EDA_BASE_FRAME::OnModify();
wxCHECK( GetScreen(), /* void */ );
if( GetScreen() )
GetScreen()->SetContentModified();
GetScreen()->SetContentModified();
m_autoSaveRequired = true;
GetCanvas()->Refresh();
if( GetCanvas() )
GetCanvas()->Refresh();
if( !GetTitle().StartsWith( wxS( "*" ) ) )
updateTitle();

View File

@ -540,12 +540,13 @@ void SYMBOL_EDIT_FRAME::Save()
void SYMBOL_EDIT_FRAME::SaveLibraryAs()
{
wxCHECK( !GetTargetLibId().GetLibNickname().empty(), /* void */ );
const wxString& libName = GetTargetLibId().GetLibNickname();
saveLibrary( libName, true );
m_treePane->GetLibTree()->RefreshLibTree();
if( !libName.IsEmpty() )
{
saveLibrary( libName, true );
m_treePane->GetLibTree()->RefreshLibTree();
}
}
@ -895,22 +896,15 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
wxLogMessage( wxS( "Can not paste: %s" ), e.Problem() );
}
}
else
else if( LIB_SYMBOL* srcSymbol = m_libMgr->GetBufferedSymbol( libId.GetLibItemName(), lib ) )
{
LIB_SYMBOL* srcSymbol = m_libMgr->GetBufferedSymbol( libId.GetLibItemName(), lib );
wxCHECK( srcSymbol, /* void */ );
newSymbols.emplace_back( new LIB_SYMBOL( *srcSymbol ) );
// Derive from same parent.
if( srcSymbol->IsAlias() )
{
std::shared_ptr< LIB_SYMBOL > srcParent = srcSymbol->GetParent().lock();
wxCHECK( srcParent, /* void */ );
newSymbols.back()->SetParent( srcParent.get() );
if( std::shared_ptr<LIB_SYMBOL> srcParent = srcSymbol->GetParent().lock() )
newSymbols.back()->SetParent( srcParent.get() );
}
}
@ -935,16 +929,17 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
void SYMBOL_EDIT_FRAME::ensureUniqueName( LIB_SYMBOL* aSymbol, const wxString& aLibrary )
{
wxCHECK( aSymbol, /* void */ );
if( aSymbol )
{
int i = 1;
wxString newName = aSymbol->GetName();
int i = 1;
wxString newName = aSymbol->GetName();
// Append a number to the name until the name is unique in the library.
while( m_libMgr->SymbolExists( newName, aLibrary ) )
newName.Printf( "%s_%d", aSymbol->GetName(), i++ );
// Append a number to the name until the name is unique in the library.
while( m_libMgr->SymbolExists( newName, aLibrary ) )
newName.Printf( "%s_%d", aSymbol->GetName(), i++ );
aSymbol->SetName( newName );
aSymbol->SetName( newName );
}
}

View File

@ -1056,12 +1056,10 @@ OPT_TOOL_EVENT EE_SELECTION_TOOL::autostartEvent( TOOL_EVENT* aEvent, EE_GRID_HE
else if( aItem->Type() == SCH_SYMBOL_T )
{
const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aItem );
const SCH_PIN* pin = symbol->GetPin( pos );
wxCHECK( symbol, OPT_TOOL_EVENT() );
const SCH_PIN* pin = symbol->GetPin( pos );
wxCHECK( pin, OPT_TOOL_EVENT() );
if( !pin )
return OPT_TOOL_EVENT();
if( !pin->IsVisible()
&& !( m_frame->eeconfig()->m_Appearance.show_hidden_pins

View File

@ -590,17 +590,18 @@ const wxString BOARD::GetLayerName( PCB_LAYER_ID aLayer ) const
bool BOARD::SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName )
{
wxCHECK( !aLayerName.IsEmpty(), false );
// no quote chars in the name allowed
if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND )
return false;
if( IsLayerEnabled( aLayer ) )
if( !aLayerName.IsEmpty() )
{
m_layers[aLayer].m_userName = aLayerName;
recalcOpposites();
return true;
// no quote chars in the name allowed
if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND )
return false;
if( IsLayerEnabled( aLayer ) )
{
m_layers[aLayer].m_userName = aLayerName;
recalcOpposites();
return true;
}
}
return false;

View File

@ -86,8 +86,6 @@ BOARD* BOARD_COMMIT::GetBoard() const
COMMIT& BOARD_COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType, BASE_SCREEN* aScreen )
{
wxCHECK( aItem, *this );
// Many operations (move, rotate, etc.) are applied directly to a group's children, so they
// must be staged as well.
if( aChangeType == CHT_MODIFY )

View File

@ -85,13 +85,15 @@ bool BOARD_ITEM::IsLocked() const
STROKE_PARAMS BOARD_ITEM::GetStroke() const
{
wxCHECK( false, STROKE_PARAMS( pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) ) );
wxFAIL_MSG( wxString( "GetStroke() not defined by " ) + GetClass() );
return STROKE_PARAMS( pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) );
}
void BOARD_ITEM::SetStroke( const STROKE_PARAMS& aStroke )
{
wxCHECK( false, /* void */ );
wxFAIL_MSG( wxString( "SetStroke() not defined by " ) + GetClass() );
}

View File

@ -441,6 +441,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData
}
else if( aTestItem->Type() == PCB_FOOTPRINT_T )
{
// Already tested above, but Coverity can't figure that out
wxCHECK( footprint, INSPECT_RESULT::CONTINUE );
if( footprint->HitTest( m_refPos, accuracy )

View File

@ -931,8 +931,6 @@ static std::optional<PNS::LINE> getPNSLine( const VECTOR2I& aStart, const VECTOR
PNS::LINKED_ITEM* startItem = pickSegment( router, aStart, layer, aStartOut );
PNS::LINKED_ITEM* endItem = pickSegment( router, aEnd, layer, aEndOut );
//wxCHECK( startItem && endItem, std::nullopt );
for( PNS::LINKED_ITEM* testItem : { startItem, endItem } )
{
if( !testItem )

View File

@ -57,7 +57,8 @@ static void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMa
void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayers,
const PCB_PLOT_PARAMS& aPlotOptions )
{
wxCHECK( aBoard && aPlotter && aLayers.size(), /* void */ );
if( !aBoard || !aPlotter || aLayers.empty() )
return;
// if a drill mark must be plotted, the copper layer needs to be plotted
// after other layers because the drill mark must be plotted as a filled

View File

@ -139,9 +139,8 @@ public:
}
}
wxCHECK( seg1 && seg2, false );
return seg1->Width() == seg2->Width();
if( seg1 && seg2 )
return seg1->Width() == seg2->Width();
}
return false;

View File

@ -197,7 +197,8 @@ bool PNS_PCBNEW_RULE_RESOLVER::IsNetTieExclusion( const PNS::ITEM* aItem,
const VECTOR2I& aCollisionPos,
const PNS::ITEM* aCollidingItem )
{
wxCHECK( aItem && aCollidingItem, false );
if( !aItem || !aCollidingItem )
return false;
std::shared_ptr<DRC_ENGINE> drcEngine = m_board->GetDesignSettings().m_DRCEngine;
BOARD_ITEM* item = aItem->BoardItem();

View File

@ -975,7 +975,8 @@ void NODE::followLine( LINKED_ITEM* aCurrent, bool aScanDirection, int& aPos, in
const VECTOR2I p = aCurrent->Anchor( aScanDirection ^ prevReversed );
const JOINT* jt = FindJoint( p, aCurrent );
wxCHECK( jt, /* void */ );
if( !jt )
break;
aCorners[aPos] = jt->Pos();
aSegments[aPos] = aCurrent;
@ -985,7 +986,9 @@ void NODE::followLine( LINKED_ITEM* aCurrent, bool aScanDirection, int& aPos, in
{
if( ( aScanDirection && jt->Pos() == aCurrent->Anchor( 0 ) )
|| ( !aScanDirection && jt->Pos() == aCurrent->Anchor( 1 ) ) )
{
aArcReversed[aPos] = true;
}
}
aPos += ( aScanDirection ? 1 : -1 );