Commit e6ec9f0a authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix crash in legacy_plugin.cpp when reading old lib files.

 fix a compil warning.
CvPcb: fix regressions :
 Shows now a void field instead of the dummy footprint name $nonane (whenthere is  no footprint selected in netlist).
 The active footprint selection changes only if a new component is selected from the component file,
 and does not change just when the next component is automatically selected, after a footprint selection.
 Speed up delete association and auto associe.
parent 92577476
...@@ -66,7 +66,8 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ) ...@@ -66,7 +66,8 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
{ {
fn = m_AliasLibNames[ii]; fn = m_AliasLibNames[ii];
if( !fn.HasExt() ) { if( !fn.HasExt() )
{
fn.SetExt( FootprintAliasFileExtension ); fn.SetExt( FootprintAliasFileExtension );
// above fails if filename have more than one point // above fails if filename have more than one point
} }
...@@ -124,8 +125,8 @@ found in the default search paths." ), ...@@ -124,8 +125,8 @@ found in the default search paths." ),
msg.Printf( _( "%d footprint aliases found." ), aliases.size() ); msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );
m_skipComponentSelect = true;
ii = 0; ii = 0;
BOOST_FOREACH( COMPONENT_INFO& component, m_components ) BOOST_FOREACH( COMPONENT_INFO& component, m_components )
{ {
bool found = false; bool found = false;
...@@ -180,4 +181,5 @@ any of the project footprint libraries." ), ...@@ -180,4 +181,5 @@ any of the project footprint libraries." ),
} }
} }
} }
m_skipComponentSelect = false;
} }
...@@ -280,7 +280,8 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) ...@@ -280,7 +280,8 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
wxASSERT(Module); wxASSERT(Module);
if( GetParent()->m_DisplayFootprintFrame ) if( GetParent()->m_DisplayFootprintFrame )
{ {
GetParent()->CreateScreenCmp(); /* refresh general */ // Refresh current selected footprint view:
GetParent()->CreateScreenCmp();
} }
if( Module ) if( Module )
......
...@@ -116,6 +116,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : ...@@ -116,6 +116,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
m_isEESchemaNetlist = false; m_isEESchemaNetlist = false;
m_KeepCvpcbOpen = false; m_KeepCvpcbOpen = false;
m_undefinedComponentCnt = 0; m_undefinedComponentCnt = 0;
m_skipComponentSelect = false;
/* Name of the document footprint list /* Name of the document footprint list
* usually located in share/modules/footprints_doc * usually located in share/modules/footprints_doc
...@@ -406,6 +407,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event ) ...@@ -406,6 +407,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
if( IsOK( this, _( "Delete selections" ) ) ) if( IsOK( this, _( "Delete selections" ) ) )
{ {
m_skipComponentSelect = true;
m_ListCmp->SetSelection( 0 ); m_ListCmp->SetSelection( 0 );
BOOST_FOREACH( COMPONENT_INFO & component, m_components ) BOOST_FOREACH( COMPONENT_INFO & component, m_components )
...@@ -414,6 +416,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event ) ...@@ -414,6 +416,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
SetNewPkg( wxEmptyString ); SetNewPkg( wxEmptyString );
} }
m_skipComponentSelect = false;
m_ListCmp->SetSelection( 0 ); m_ListCmp->SetSelection( 0 );
m_undefinedComponentCnt = m_components.size(); m_undefinedComponentCnt = m_components.size();
} }
...@@ -506,18 +509,22 @@ void CVPCB_MAINFRAME::OnLeftDClick( wxListEvent& event ) ...@@ -506,18 +509,22 @@ void CVPCB_MAINFRAME::OnLeftDClick( wxListEvent& event )
/* Called when clicking on a component in component list window /* Called when clicking on a component in component list window
* * Updates the filtered foorprint list, if the filtered list option is selected * * Updates the filtered footprint list, if the filtered list option is selected
* * Updates the current selected footprint in footprint list * * Updates the current selected footprint in footprint list
* * Updates the footprint shown in footprint display window (if opened) * * Updates the footprint shown in footprint display window (if opened)
*/ */
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
{ {
if( m_skipComponentSelect )
return;
#define REDRAW_LIST true #define REDRAW_LIST true
#define SELECT_FULL_LIST true #define SELECT_FULL_LIST true
int selection = -1; int selection = -1;
if( !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) if( !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST )
&& !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST )) && !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST )
)
m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST );
else else
...@@ -553,7 +560,12 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) ...@@ -553,7 +560,12 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
return; return;
// Preview of the already assigned footprint. // Preview of the already assigned footprint.
// Find the footprint that was already choosen for this component and select it. // Find the footprint that was already choosen for this component and select it,
// but only if the selection is made from the component list.
// If the selection is made from the footprint list, do not change the current selected footprint.
if( FindFocus() == m_ListCmp )
{
wxString module = *(&m_components[ selection ].m_Footprint); wxString module = *(&m_components[ selection ].m_Footprint);
bool found = false; bool found = false;
...@@ -582,7 +594,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) ...@@ -582,7 +594,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
CreateScreenCmp(); CreateScreenCmp();
} }
} }
}
SendMessageToEESCHEMA(); SendMessageToEESCHEMA();
DisplayStatus(); DisplayStatus();
......
...@@ -46,6 +46,8 @@ protected: ...@@ -46,6 +46,8 @@ protected:
int m_undefinedComponentCnt; int m_undefinedComponentCnt;
bool m_modified; bool m_modified;
bool m_isEESchemaNetlist; bool m_isEESchemaNetlist;
bool m_skipComponentSelect; // true to skip OnSelectComponent event
// (in automatic selection/deletion of associations)
PARAM_CFG_ARRAY m_projectFileParams; PARAM_CFG_ARRAY m_projectFileParams;
public: public:
......
...@@ -68,7 +68,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist() ...@@ -68,7 +68,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
netList_Reader.m_UseCmpFile = false; netList_Reader.m_UseCmpFile = false;
netList_Reader.SetFilesnames( m_NetlistFileName.GetFullPath(), wxEmptyString ); netList_Reader.SetFilesnames( m_NetlistFileName.GetFullPath(), wxEmptyString );
// True to read footprint filters section: true for CvPcb, false pro Pcbnew // True to read footprint filters section: true for CvPcb, false for Pcbnew
netList_Reader.ReadLibpartSectionSetOpt( true ); netList_Reader.ReadLibpartSectionSetOpt( true );
bool success = netList_Reader.ReadNetList( netfile ); bool success = netList_Reader.ReadNetList( netfile );
...@@ -79,9 +79,15 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist() ...@@ -79,9 +79,15 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
} }
// Now copy footprints info into Cvpcb list: // Now copy footprints info into Cvpcb list:
// We also remove footprint name if it is "$noname"
// because this is a dummy name,, not an actual name
COMPONENT_INFO_LIST& cmpInfo = netList_Reader.GetComponentInfoList(); COMPONENT_INFO_LIST& cmpInfo = netList_Reader.GetComponentInfoList();
for( unsigned ii = 0; ii < cmpInfo.size(); ii++ ) for( unsigned ii = 0; ii < cmpInfo.size(); ii++ )
{
m_components.push_back( cmpInfo[ii] ); m_components.push_back( cmpInfo[ii] );
if( cmpInfo[ii]->m_Footprint == wxT( "$noname" ) )
cmpInfo[ii]->m_Footprint.Empty();
}
cmpInfo.clear(); // cmpInfo is no more owner of the list. cmpInfo.clear(); // cmpInfo is no more owner of the list.
// Sort components by reference: // Sort components by reference:
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 17 2012) // C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -104,7 +104,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx ...@@ -104,7 +104,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
m_staticText9->Wrap( -1 ); m_staticText9->Wrap( -1 );
fgSizer1->Add( m_staticText9, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); fgSizer1->Add( m_staticText9, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_spinRepeatHorizontal = new wxSpinCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, -500, 500, 0 ); m_spinRepeatHorizontal = new wxSpinCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, -5000, 5000, 0 );
fgSizer1->Add( m_spinRepeatHorizontal, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); fgSizer1->Add( m_spinRepeatHorizontal, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticRepeatXUnits = new wxStaticText( m_panel1, wxID_ANY, _("mils"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticRepeatXUnits = new wxStaticText( m_panel1, wxID_ANY, _("mils"), wxDefaultPosition, wxDefaultSize, 0 );
...@@ -115,7 +115,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx ...@@ -115,7 +115,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
m_staticText12->Wrap( -1 ); m_staticText12->Wrap( -1 );
fgSizer1->Add( m_staticText12, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); fgSizer1->Add( m_staticText12, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_spinRepeatVertical = new wxSpinCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, -500, 500, 100 ); m_spinRepeatVertical = new wxSpinCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, -5000, 5000, 100 );
fgSizer1->Add( m_spinRepeatVertical, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); fgSizer1->Add( m_spinRepeatVertical, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticRepeatYUnits = new wxStaticText( m_panel1, wxID_ANY, _("mils"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticRepeatYUnits = new wxStaticText( m_panel1, wxID_ANY, _("mils"), wxDefaultPosition, wxDefaultSize, 0 );
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 17 2012) // C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
......
...@@ -98,10 +98,10 @@ public: ...@@ -98,10 +98,10 @@ public:
int m_CntRot180; ///< Automatic placement : cost ( 0..10 ) int m_CntRot180; ///< Automatic placement : cost ( 0..10 )
///< for 180 degrees rotation (UP <->Down) ///< for 180 degrees rotation (UP <->Down)
wxSize m_Ext; /* Automatic placement margin around the module */ wxSize m_Ext; // Margin around the module, in automatic placement
double m_Surface; // Bounding box area double m_Surface; // Bounding box area
unsigned long m_Link; /* Temporary variable ( used in editions, ...) */ time_t m_Link; // Temporary logical link used in edition
long m_LastEdit_Time; long m_LastEdit_Time;
wxString m_Path; wxString m_Path;
......
...@@ -935,10 +935,11 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() ...@@ -935,10 +935,11 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
data = strtok( (char*) data+1, delims ); data = strtok( (char*) data+1, delims );
// data is now a two character long string // data is now a two character long string
if( data[0] == 'F' ) // Note: some old files do not have this field
if( data && data[0] == 'F' )
module->SetLocked( true ); module->SetLocked( true );
if( data[1] == 'P' ) if( data && data[1] == 'P' )
module->SetIsPlaced( true ); module->SetIsPlaced( true );
module->SetPosition( wxPoint( pos_x, pos_y ) ); module->SetPosition( wxPoint( pos_x, pos_y ) );
...@@ -1321,7 +1322,8 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) ...@@ -1321,7 +1322,8 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
case 'A': shape = S_ARC; break; case 'A': shape = S_ARC; break;
case 'P': shape = S_POLYGON; break; case 'P': shape = S_POLYGON; break;
default: default:
m_error.Printf( wxT( "Unknown EDGE_MODULE type '%s'" ), FROM_UTF8( line ).GetData() ); m_error.Printf( wxT( "Unknown EDGE_MODULE type '%s' line %d" ),
FROM_UTF8( line ).GetData(), m_reader->LineNumber() );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
} }
......
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