Work around annoying wxWidgets assert.

This commit is contained in:
Jeff Young 2021-08-10 12:59:53 +01:00
parent c327768a93
commit c536a4c4f2
12 changed files with 26 additions and 28 deletions

View File

@ -71,7 +71,7 @@ DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESO
m_btnMoveUp->SetBitmap( KiBitmap( BITMAPS::small_up ) );
m_btnMoveDown->SetBitmap( KiBitmap( BITMAPS::small_down ) );
m_EnvVars->DeleteRows( 0, m_EnvVars->GetNumberRows() );
m_EnvVars->ClearRows();
m_EnvVars->AppendCols( 1 ); // for the isExternal flags
m_EnvVars->HideCol( TV_FLAG_COL );
m_EnvVars->UseNativeColHeader( true );
@ -96,7 +96,7 @@ DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESO
if( m_resolver )
{
m_SearchPaths->DeleteRows( 0, m_SearchPaths->GetNumberRows() );
m_SearchPaths->ClearRows();
m_SearchPaths->UseNativeColHeader( true );
// prohibit these characters in the alias names: []{}()%~<>"='`;:.,&?/\|$

View File

@ -241,9 +241,7 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
for( const wxString& candidate : m_netNames )
netToNetclassMap[ candidate ] = wxEmptyString;
if( m_netclassGrid->GetNumberRows() )
m_netclassGrid->DeleteRows( 0, m_netclassGrid->GetNumberRows() );
m_netclassGrid->ClearRows();
m_netclassGrid->AppendRows((int) m_netclasses->GetCount() + 1 ); // + 1 for default netclass
// enter the Default NETCLASS.
@ -272,8 +270,7 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
}
}
if( m_membershipGrid->GetNumberRows() )
m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
m_membershipGrid->ClearRows();
// add currently-assigned and candidate netnames to membership lists
for( const std::pair<const wxString, wxString>& ii : netToNetclassMap )

View File

@ -48,7 +48,7 @@ PANEL_TEXT_VARIABLES::PANEL_TEXT_VARIABLES( wxWindow* aParent, PROJECT* aProject
m_btnAddTextVar->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
m_btnDeleteTextVar->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
m_TextVars->DeleteRows( 0, m_TextVars->GetNumberRows() );
m_TextVars->ClearRows();
// prohibit these characters in the alias names: []{}()%~<>"='`;:.,&?/\|$
m_nameValidator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST );

View File

@ -380,7 +380,7 @@ static bool sort_by_libid( const SYMBOL_CANDIDATE& candidate1, const SYMBOL_CAND
void DIALOG_EDIT_SYMBOLS_LIBID::initDlg()
{
// Clear the FormBuilder rows
m_grid->DeleteRows( 0, m_grid->GetNumberRows() );
m_grid->ClearRows();
m_isModified = false;

View File

@ -107,9 +107,7 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToGrid()
{
m_grid->Freeze();
if( m_grid->GetNumberRows() )
m_grid->DeleteRows( 0, m_grid->GetNumberRows() );
m_grid->ClearRows();
m_grid->AppendRows( m_fields.size() );
for( int row = 0; row < m_grid->GetNumberRows(); ++row )

View File

@ -903,7 +903,7 @@ void PANEL_SYM_LIB_TABLE::populateEnvironReadOnlyTable()
std::set< wxString > unique;
// clear the table
m_path_subs_grid->DeleteRows( 0, m_path_subs_grid->GetNumberRows() );
m_path_subs_grid->ClearRows();
for( SYMBOL_LIB_TABLE_GRID* tbl : { global_model(), project_model() } )
{

View File

@ -98,6 +98,17 @@ public:
*/
void ShowEditorOnMouseUp() { m_waitForSlowClick = true; }
/**
* wxWidgets recently added an ASSERT which fires if the position is greater than or equal
* to the number of rows (even if the delete count is 0). Needless to say, this makes using
* DeleteRows for clearing a lot more cumbersome so we add a helper here.
*/
void ClearRows()
{
if( GetNumberRows() )
DeleteRows( 0, GetNumberRows() );
}
protected:
/**
* A re-implementation of wxGrid::DrawColLabel which left-aligns the first column when

View File

@ -1007,7 +1007,7 @@ void PANEL_FP_LIB_TABLE::populateEnvironReadOnlyTable()
std::set< wxString > unique;
// clear the table
m_path_subs_grid->DeleteRows( 0, m_path_subs_grid->GetNumberRows() );
m_path_subs_grid->ClearRows();
for( FP_LIB_TABLE_GRID* tbl : { global_model(), project_model() } )
{

View File

@ -147,7 +147,7 @@ void PANEL_FP_PROPERTIES_3D_MODEL::ReloadModelsFromFootprint()
#endif
m_shapes3D_list.clear();
m_modelsGrid->DeleteRows( 0, m_modelsGrid->GetNumberRows() );
m_modelsGrid->ClearRows();
wxString origPath, alias, shortPath;
FILENAME_RESOLVER* res = m_frame->Prj().Get3DCacheManager()->GetResolver();

View File

@ -172,8 +172,7 @@ bool PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow()
{
m_grid->Freeze();
if( m_grid->GetNumberRows() != 0 )
m_grid->DeleteRows( 0, m_grid->GetNumberRows() );
m_grid->ClearRows();
const auto& orderedPlugins = m_frame->GetOrderedActionPlugins();
m_grid->AppendRows( orderedPlugins.size() );

View File

@ -112,14 +112,9 @@ PANEL_SETUP_TRACKS_AND_VIAS::~PANEL_SETUP_TRACKS_AND_VIAS()
bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataToWindow()
{
if( m_trackWidthsGrid->GetNumberRows() > 0 )
m_trackWidthsGrid->DeleteRows( 0, m_trackWidthsGrid->GetNumberRows() );
if( m_viaSizesGrid->GetNumberRows() > 0 )
m_viaSizesGrid->DeleteRows( 0, m_viaSizesGrid->GetNumberRows() );
if( m_diffPairsGrid->GetNumberRows() > 0 )
m_diffPairsGrid->DeleteRows( 0, m_diffPairsGrid->GetNumberRows() );
m_trackWidthsGrid->ClearRows();
m_viaSizesGrid->ClearRows();
m_diffPairsGrid->ClearRows();
// Skip the first item, which is the current netclass value
for( unsigned ii = 1; ii < m_BrdSettings->m_TrackWidthList.size(); ii++ )

View File

@ -400,9 +400,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
wxArrayString hintsList = footprintWizard->GetParameterHints( m_parameterGridPage );
// Dimension the wxGrid
if( m_parameterGrid->GetNumberRows() > 0 )
m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );
m_parameterGrid->ClearRows();
m_parameterGrid->AppendRows( namesList.size() );
wxString designator, name, value, units, hint;