Improve template selector for macOS

Fixes: lp:1492577 (and probably also lp:1672116).
*https://bugs.launchpad.net/kicad/+bug/1492577
*https://bugs.launchpad.net/kicad/+bug/1672116

- Fixes a race condition causing the wrong page to be selected in
  `OnPageChange`
- Allows the validate path and browse button to refresh the
  template page even when the path was not changed. This is needed
  since on OSX the page needs to be active for the templates to be
  rendered.
This commit is contained in:
Seppe Stas 2017-09-18 15:48:00 +02:00 committed by jean-pierre charras
parent 48393c605e
commit 3b7fbad1b9
1 changed files with 1 additions and 7 deletions

View File

@ -107,7 +107,7 @@ void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event)
void DIALOG_TEMPLATE_SELECTOR::OnPageChange( wxNotebookEvent& event ) void DIALOG_TEMPLATE_SELECTOR::OnPageChange( wxNotebookEvent& event )
{ {
int page = m_notebook->GetSelection(); int page = event.GetSelection();
if( page != wxNOT_FOUND && (unsigned)page < m_panels.size() ) if( page != wxNOT_FOUND && (unsigned)page < m_panels.size() )
m_tcTemplatePath->SetValue( m_panels[page]->GetPath() ); m_tcTemplatePath->SetValue( m_panels[page]->GetPath() );
@ -219,9 +219,6 @@ void DIALOG_TEMPLATE_SELECTOR::onDirectoryBrowseClicked( wxCommandEvent& event )
m_tcTemplatePath->SetValue( dirName.GetFullPath() ); m_tcTemplatePath->SetValue( dirName.GetFullPath() );
if( currPath == m_tcTemplatePath->GetValue() )
return; // No change
// Rebuild the page from the new templates path: // Rebuild the page from the new templates path:
replaceCurrentPage(); replaceCurrentPage();
} }
@ -236,9 +233,6 @@ void DIALOG_TEMPLATE_SELECTOR::onValidatePath( wxCommandEvent& event )
wxString currPath = m_tcTemplatePath->GetValue(); wxString currPath = m_tcTemplatePath->GetValue();
if( currPath == m_panels[page]->GetPath() ) // No change
return;
wxFileName fn; wxFileName fn;
fn.AssignDir( m_tcTemplatePath->GetValue() ); fn.AssignDir( m_tcTemplatePath->GetValue() );
fn.Normalize(); fn.Normalize();