Commit 5821d4bc authored by Wayne Stambaugh's avatar Wayne Stambaugh

Footprint library table fixes.

* Pcbnew: catch exceptions when saving changes to footprint library table.
* Pcbnew: update footprint viewer library list if open when footprint library
  table changes.
* CvPcb: update library list when footprint library table changes.
* Minor coding policy fixes.
parent 76fed4f9
...@@ -514,12 +514,24 @@ void CVPCB_MAINFRAME::ConfigCvpcb( wxCommandEvent& event ) ...@@ -514,12 +514,24 @@ void CVPCB_MAINFRAME::ConfigCvpcb( wxCommandEvent& event )
#if defined( USE_FP_LIB_TABLE ) #if defined( USE_FP_LIB_TABLE )
void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
{ {
bool tableChanged = false;
int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable ); int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable );
if( r & 1 ) if( r & 1 )
{
try
{ {
FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() );
m_globalFootprintTable->Format( &sf, 0 ); m_globalFootprintTable->Format( &sf, 0 );
tableChanged = true;
}
catch( IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Error occurred saving the global footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
} }
if( r & 2 ) if( r & 2 )
...@@ -528,9 +540,23 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) ...@@ -528,9 +540,23 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
fn.SetName( FP_LIB_TABLE::GetFileName() ); fn.SetName( FP_LIB_TABLE::GetFileName() );
fn.SetExt( wxEmptyString ); fn.SetExt( wxEmptyString );
try
{
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() ); FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
m_footprintLibTable->Format( &sf, 0 ); m_footprintLibTable->Format( &sf, 0 );
tableChanged = true;
}
catch( IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Error occurred saving the global footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
} }
if( tableChanged )
BuildLIBRARY_LISTBOX();
} }
#endif #endif
......
...@@ -95,10 +95,6 @@ public: ...@@ -95,10 +95,6 @@ public:
virtual EDA_COLOR_T GetGridColor( void ) const; virtual EDA_COLOR_T GetGridColor( void ) const;
private:
void OnSize( wxSizeEvent& event );
/** /**
* Function ReCreateLibraryList * Function ReCreateLibraryList
* *
...@@ -107,6 +103,10 @@ private: ...@@ -107,6 +103,10 @@ private:
*/ */
void ReCreateLibraryList(); void ReCreateLibraryList();
private:
void OnSize( wxSizeEvent& event );
void ReCreateFootprintList(); void ReCreateFootprintList();
void OnIterateFootprintList( wxCommandEvent& event ); void OnIterateFootprintList( wxCommandEvent& event );
void DisplayLibInfos(); void DisplayLibInfos();
...@@ -200,9 +200,9 @@ private: ...@@ -200,9 +200,9 @@ private:
* Virtual functions, not used here, but needed by PCB_BASE_FRAME * Virtual functions, not used here, but needed by PCB_BASE_FRAME
* (virtual pure functions ) * (virtual pure functions )
*/ */
void OnLeftDClick(wxDC*, const wxPoint&) {} void OnLeftDClick( wxDC*, const wxPoint& ) {}
void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {} void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) {}
void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {} void SaveCopyInUndoList( PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) {}
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
......
...@@ -87,6 +87,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -87,6 +87,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
case ID_PCB_LIB_TABLE_EDIT: case ID_PCB_LIB_TABLE_EDIT:
{ {
bool tableChanged = false;
int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable ); int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable );
if( r & 1 ) if( r & 1 )
...@@ -95,6 +96,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -95,6 +96,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
{ {
FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() );
m_globalFootprintTable->Format( &sf, 0 ); m_globalFootprintTable->Format( &sf, 0 );
tableChanged = true;
} }
catch( IO_ERROR& ioe ) catch( IO_ERROR& ioe )
{ {
...@@ -114,6 +116,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -114,6 +116,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
try try
{ {
m_footprintLibTable->Save( fn ); m_footprintLibTable->Save( fn );
tableChanged = true;
} }
catch( IO_ERROR& ioe ) catch( IO_ERROR& ioe )
{ {
...@@ -123,6 +126,11 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -123,6 +126,11 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
} }
} }
if( tableChanged && FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer() != NULL )
{
FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer()->ReCreateLibraryList();
}
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment