diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 77e98099b3..11fb2d261d 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -514,12 +514,24 @@ void CVPCB_MAINFRAME::ConfigCvpcb( wxCommandEvent& event ) #if defined( USE_FP_LIB_TABLE ) void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) { + bool tableChanged = false; int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable ); if( r & 1 ) { - FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); - m_globalFootprintTable->Format( &sf, 0 ); + try + { + FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); + 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 ) @@ -528,9 +540,23 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) fn.SetName( FP_LIB_TABLE::GetFileName() ); fn.SetExt( wxEmptyString ); - FILE_OUTPUTFORMATTER sf( fn.GetFullPath() ); - m_footprintLibTable->Format( &sf, 0 ); + try + { + FILE_OUTPUTFORMATTER sf( fn.GetFullPath() ); + 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 diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 5459f59d58..9f4cc53893 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -97,7 +97,7 @@ protected: TOOL_MANAGER* m_toolManager; TOOL_DISPATCHER* m_toolDispatcher; - + void updateGridSelectBox(); void updateZoomSelectBox(); virtual void unitsChangeRefresh(); diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index dcdd4ff5b8..bcdf51c56f 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -111,7 +111,7 @@ protected: DRC* m_drc; ///< the DRC controller, see drc.cpp - PARAM_CFG_ARRAY m_configSettings; ///< List of Pcbnew configuration settings. + PARAM_CFG_ARRAY m_configSettings; ///< List of Pcbnew configuration settings. wxString m_lastNetListRead; ///< Last net list read with relative path. bool m_useCmpFileForFpNames; ///< is true, use the .cmp file from CvPcb, else use the netlist @@ -120,7 +120,7 @@ protected: void setupTools(); void destroyTools(); void onGenericCommand( wxCommandEvent& aEvent ); - + // we'll use lower case function names for private member functions. void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu ); void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu ); diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h index 71d105f28a..c833e5c10c 100644 --- a/pcbnew/modview_frame.h +++ b/pcbnew/modview_frame.h @@ -95,10 +95,6 @@ public: virtual EDA_COLOR_T GetGridColor( void ) const; -private: - - void OnSize( wxSizeEvent& event ); - /** * Function ReCreateLibraryList * @@ -107,6 +103,10 @@ private: */ void ReCreateLibraryList(); +private: + + void OnSize( wxSizeEvent& event ); + void ReCreateFootprintList(); void OnIterateFootprintList( wxCommandEvent& event ); void DisplayLibInfos(); @@ -200,9 +200,9 @@ private: * Virtual functions, not used here, but needed by PCB_BASE_FRAME * (virtual pure functions ) */ - void OnLeftDClick(wxDC*, const wxPoint&) {} - void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {} - void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {} + void OnLeftDClick( wxDC*, const wxPoint& ) {} + void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) {} + void SaveCopyInUndoList( PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) {} DECLARE_EVENT_TABLE() diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 9b4cf28744..79f0af03d2 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -87,6 +87,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) case ID_PCB_LIB_TABLE_EDIT: { + bool tableChanged = false; int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable ); if( r & 1 ) @@ -95,6 +96,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); m_globalFootprintTable->Format( &sf, 0 ); + tableChanged = true; } catch( IO_ERROR& ioe ) { @@ -114,6 +116,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) try { m_footprintLibTable->Save( fn ); + tableChanged = true; } catch( IO_ERROR& ioe ) { @@ -123,6 +126,11 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } + + if( tableChanged && FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer() != NULL ) + { + FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer()->ReCreateLibraryList(); + } } break;