Ask user before throwing away changes to DRC Rules.
Fixes https://gitlab.com/kicad/code/kicad/issues/5135
This commit is contained in:
parent
de6314e3b5
commit
e1c449902d
|
@ -1187,7 +1187,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnClose( wxCloseEvent& event )
|
|||
|
||||
if( m_dataModel->IsEdited() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, wxEmptyString,
|
||||
if( !HandleUnsavedChanges( this, _( "Save changes?" ),
|
||||
[&]()->bool { return TransferDataFromWindow(); } ) )
|
||||
{
|
||||
event.Veto();
|
||||
|
|
|
@ -727,21 +727,36 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnClose( wxCloseEvent& event )
|
|||
// This is a cancel, so commit quietly as we're going to throw the results away anyway.
|
||||
m_grid->CommitPendingChanges( true );
|
||||
|
||||
int retval = wxCANCEL;
|
||||
|
||||
if( m_dataModel->IsEdited() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, wxEmptyString,
|
||||
[&]()->bool { return TransferDataFromWindow(); } ) )
|
||||
if( HandleUnsavedChanges( this, _( "Save changes?" ),
|
||||
[&]()->bool
|
||||
{
|
||||
if( TransferDataFromWindow() )
|
||||
{
|
||||
retval = wxOK;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} ) )
|
||||
{
|
||||
if( IsQuasiModal() )
|
||||
EndQuasiModal( retval );
|
||||
else
|
||||
EndModal( retval );
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.Veto();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( IsQuasiModal() )
|
||||
EndQuasiModal( wxID_CANCEL );
|
||||
else if( IsModal() )
|
||||
EndModal( wxID_CANCEL );
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ class PAGED_DIALOG : public DIALOG_SHIM
|
|||
private:
|
||||
wxString m_title;
|
||||
|
||||
bool m_dirty;
|
||||
|
||||
wxString m_errorMessage;
|
||||
wxWindow* m_errorCtrl; // the control associated with m_errorMessage
|
||||
int m_errorRow; // the row if m_errorCtrl is a grid
|
||||
|
@ -62,6 +64,8 @@ public:
|
|||
|
||||
void SetInitialPage( const wxString& aPage, const wxString& aParentPage = wxEmptyString );
|
||||
|
||||
void SetModified() { m_modified = true; }
|
||||
|
||||
void SetError( const wxString& aMessage, const wxString& aPageName, int aCtrlId, int aRow = -1,
|
||||
int aCol = -1 );
|
||||
|
||||
|
@ -74,15 +78,17 @@ protected:
|
|||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
void OnClose( wxCloseEvent& event );
|
||||
void OnCancel( wxCommandEvent& event );
|
||||
virtual void OnAuxiliaryAction( wxCommandEvent& event ) { event.Skip(); }
|
||||
void OnResetButton( wxCommandEvent& aEvent );
|
||||
void OnUpdateUI( wxUpdateUIEvent& event );
|
||||
void OnPageChange( wxBookCtrlEvent& event );
|
||||
void OnPageChanging( wxBookCtrlEvent& aEvent );
|
||||
|
||||
PAGED_TREEBOOK* m_treebook;
|
||||
wxButton* m_auxiliaryButton;
|
||||
wxButton* m_resetButton;
|
||||
wxButton* m_cancelButton;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
|||
{
|
||||
constexpr int flags = wxSTC_FIND_REGEXP| wxSTC_FIND_POSIX;
|
||||
|
||||
m_Parent->SetModified();
|
||||
m_textEditor->SearchAnchor();
|
||||
|
||||
int i = std::max( 0, m_textEditor->SearchPrev( flags, "\( *rule " ) );
|
||||
|
|
Loading…
Reference in New Issue