Improve safety around un-committed grid changes.
This commit is contained in:
parent
a6d10d6e28
commit
afacb6e7cb
|
@ -775,12 +775,19 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI( wxUpdateUIEvent& event )
|
|||
m_delayedFocusGrid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn );
|
||||
|
||||
if( !m_delayedErrorMessage.IsEmpty() )
|
||||
DisplayErrorMessage( this, m_delayedErrorMessage );
|
||||
{
|
||||
// We will re-enter this routine when the error dialog is displayed, so make
|
||||
// sure we don't keep putting up more dialogs.
|
||||
wxString msg = m_delayedErrorMessage;
|
||||
m_delayedErrorMessage = wxEmptyString;
|
||||
|
||||
// Do not use DisplayErrorMessage(); it screws up window order on Mac
|
||||
DisplayError( nullptr, msg );
|
||||
}
|
||||
|
||||
m_delayedFocusGrid->EnableCellEditControl( true );
|
||||
m_delayedFocusGrid->ShowCellEditControl();
|
||||
|
||||
m_delayedErrorMessage = wxEmptyString;
|
||||
m_delayedFocusGrid = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -546,8 +546,8 @@ void DIALOG_EDIT_COMPONENTS_LIBID::AddRowToGrid( bool aMarkRow, const wxString&
|
|||
|
||||
bool DIALOG_EDIT_COMPONENTS_LIBID::validateLibIds()
|
||||
{
|
||||
// Commit any pending edits
|
||||
m_grid->DisableCellEditControl();
|
||||
if( !m_grid->CommitPendingChanges() )
|
||||
return false;
|
||||
|
||||
int row_max = m_grid->GetNumberRows() - 1;
|
||||
|
||||
|
|
|
@ -128,8 +128,6 @@ DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aP
|
|||
m_allow180Label->SetFont( infoFont );
|
||||
m_libraryIDLabel->SetFont( infoFont );
|
||||
m_staticLibraryID->SetFont( infoFont );
|
||||
m_sheetPathLabel->SetFont( infoFont );
|
||||
m_staticSheetPath->SetFont( infoFont );
|
||||
m_staticTextInfoValNeg->SetFont( infoFont );
|
||||
m_staticTextInfoValPos->SetFont( infoFont );
|
||||
m_staticTextInfoCopper->SetFont( infoFont );
|
||||
|
@ -373,9 +371,8 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow()
|
|||
|
||||
select3DModel( 0 ); // will clamp idx within bounds
|
||||
|
||||
// Show the footprint's ID and schematic reference.
|
||||
// Show the footprint's ID.
|
||||
m_staticLibraryID->SetLabel( m_footprint->GetFPID().Format() );
|
||||
m_staticSheetPath->SetLabel( m_footprint->GetPath() );
|
||||
|
||||
Layout();
|
||||
adjustGridColumns( m_itemsGrid->GetRect().GetWidth());
|
||||
|
@ -424,6 +421,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelCellChanged( wxGridEvent& aEvent )
|
|||
m_delayedFocusGrid = m_modelsGrid;
|
||||
m_delayedFocusRow = aEvent.GetRow();
|
||||
m_delayedFocusColumn = aEvent.GetCol();
|
||||
aEvent.Veto();
|
||||
}
|
||||
|
||||
// if the user has specified an alias in the name then prepend ':'
|
||||
|
@ -450,6 +448,8 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelCellChanged( wxGridEvent& aEvent )
|
|||
|
||||
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnRemove3DModel( wxCommandEvent& )
|
||||
{
|
||||
m_modelsGrid->CommitPendingChanges( true /* quiet mode */ );
|
||||
|
||||
int idx = m_modelsGrid->GetGridCursorRow();
|
||||
|
||||
if( idx >= 0 )
|
||||
|
@ -465,6 +465,9 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnRemove3DModel( wxCommandEvent& )
|
|||
|
||||
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel( wxCommandEvent& )
|
||||
{
|
||||
if( !m_modelsGrid->CommitPendingChanges() )
|
||||
return;
|
||||
|
||||
PROJECT& prj = Prj();
|
||||
MODULE_3D_SETTINGS model;
|
||||
|
||||
|
@ -525,6 +528,9 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel( wxCommandEvent& )
|
|||
|
||||
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DRow( wxCommandEvent& )
|
||||
{
|
||||
if( !m_modelsGrid->CommitPendingChanges() )
|
||||
return;
|
||||
|
||||
MODULE_3D_SETTINGS model;
|
||||
|
||||
model.m_Preview = true;
|
||||
|
@ -545,8 +551,8 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DRow( wxCommandEvent& )
|
|||
|
||||
bool DIALOG_FOOTPRINT_BOARD_EDITOR::Validate()
|
||||
{
|
||||
// Commit any pending in-place edits and close the editor
|
||||
m_itemsGrid->DisableCellEditControl();
|
||||
if( !m_itemsGrid->CommitPendingChanges() )
|
||||
return false;
|
||||
|
||||
if( !DIALOG_SHIM::Validate() )
|
||||
return false;
|
||||
|
@ -718,6 +724,9 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow()
|
|||
|
||||
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField( wxCommandEvent& )
|
||||
{
|
||||
if( !m_itemsGrid->CommitPendingChanges() )
|
||||
return;
|
||||
|
||||
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
||||
TEXTE_MODULE textMod( m_footprint );
|
||||
|
||||
|
@ -749,29 +758,29 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField( wxCommandEvent& )
|
|||
|
||||
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnDeleteField( wxCommandEvent& )
|
||||
{
|
||||
m_itemsGrid->CommitPendingChanges( true /* quiet mode */ );
|
||||
|
||||
int rowCount = m_itemsGrid->GetNumberRows();
|
||||
int curRow = m_itemsGrid->GetGridCursorRow();
|
||||
|
||||
if( curRow < 0 || curRow >= (int) m_texts->size() )
|
||||
if( curRow < 0 )
|
||||
return;
|
||||
|
||||
if( curRow < 2 )
|
||||
else if( curRow < 2 )
|
||||
{
|
||||
DisplayError( nullptr, _( "Reference and value are mandatory." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
auto start = m_texts->begin() + curRow;
|
||||
m_texts->erase( start, start + 1 );
|
||||
m_texts->erase( m_texts->begin() + curRow );
|
||||
|
||||
// notify the grid
|
||||
wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
|
||||
m_itemsGrid->ProcessTableMessage( msg );
|
||||
|
||||
if( curRow == rowCount - 1 )
|
||||
if( m_itemsGrid->GetNumberRows() > 0 )
|
||||
{
|
||||
m_itemsGrid->MakeCellVisible( curRow-1, m_itemsGrid->GetGridCursorCol() );
|
||||
m_itemsGrid->SetGridCursor( curRow-1, m_itemsGrid->GetGridCursorCol() );
|
||||
m_itemsGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_itemsGrid->GetGridCursorCol() );
|
||||
m_itemsGrid->SetGridCursor( std::max( 0, curRow-1 ), m_itemsGrid->GetGridCursorCol() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -336,6 +336,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::On3DModelCellChanged( wxGridEvent& aEvent )
|
|||
m_delayedFocusGrid = m_modelsGrid;
|
||||
m_delayedFocusRow = aEvent.GetRow();
|
||||
m_delayedFocusColumn = aEvent.GetCol();
|
||||
aEvent.Veto();
|
||||
}
|
||||
|
||||
// if the user has specified an alias in the name then prepend ':'
|
||||
|
|
Loading…
Reference in New Issue