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,37 +560,42 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) ...@@ -553,37 +560,42 @@ 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,
wxString module = *(&m_components[ selection ].m_Footprint); // 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.
bool found = false; if( FindFocus() == m_ListCmp )
for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ )
{ {
wxString footprintName; wxString module = *(&m_components[ selection ].m_Footprint);
wxString msg = (*m_FootprintList->m_ActiveFootprintList)[ii];
msg.Trim( true );
msg.Trim( false );
footprintName = msg.AfterFirst( wxChar( ' ' ) );
if( module.Cmp( footprintName ) == 0 ) bool found = false;
for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ )
{ {
m_FootprintList->SetSelection( ii, true ); wxString footprintName;
found = true; wxString msg = (*m_FootprintList->m_ActiveFootprintList)[ii];
break; msg.Trim( true );
msg.Trim( false );
footprintName = msg.AfterFirst( wxChar( ' ' ) );
if( module.Cmp( footprintName ) == 0 )
{
m_FootprintList->SetSelection( ii, true );
found = true;
break;
}
} }
} if( ! found )
if( ! found )
{
int ii = m_FootprintList->GetSelection();
if ( ii >= 0 )
m_FootprintList->SetSelection( ii, false );
if( m_DisplayFootprintFrame )
{ {
CreateScreenCmp(); int ii = m_FootprintList->GetSelection();
if ( ii >= 0 )
m_FootprintList->SetSelection( ii, false );
if( m_DisplayFootprintFrame )
{
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!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EESCHEMA_OPTIONS_BASE_H__ #ifndef __DIALOG_EESCHEMA_OPTIONS_BASE_H__
#define __DIALOG_EESCHEMA_OPTIONS_BASE_H__ #define __DIALOG_EESCHEMA_OPTIONS_BASE_H__
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/choice.h> #include <wx/choice.h>
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/bitmap.h> #include <wx/bitmap.h>
#include <wx/image.h> #include <wx/image.h>
#include <wx/icon.h> #include <wx/icon.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/notebook.h> #include <wx/notebook.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EESCHEMA_OPTIONS_BASE /// Class DIALOG_EESCHEMA_OPTIONS_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_EESCHEMA_OPTIONS_BASE : public wxDialog class DIALOG_EESCHEMA_OPTIONS_BASE : public wxDialog
{ {
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private: private:
// Private event handlers // Private event handlers
void _wxFB_OnChooseUnits( wxCommandEvent& event ){ OnChooseUnits( event ); } void _wxFB_OnChooseUnits( wxCommandEvent& event ){ OnChooseUnits( event ); }
void _wxFB_OnMiddleBtnPanEnbl( wxCommandEvent& event ){ OnMiddleBtnPanEnbl( event ); } void _wxFB_OnMiddleBtnPanEnbl( wxCommandEvent& event ){ OnMiddleBtnPanEnbl( event ); }
protected: protected:
enum enum
{ {
ID_M_SPINAUTOSAVEINTERVAL = 1000, ID_M_SPINAUTOSAVEINTERVAL = 1000,
xwID_ANY xwID_ANY
}; };
wxNotebook* m_notebook1; wxNotebook* m_notebook1;
wxPanel* m_panel1; wxPanel* m_panel1;
wxStaticText* m_staticText2; wxStaticText* m_staticText2;
wxChoice* m_choiceUnits; wxChoice* m_choiceUnits;
wxStaticText* m_staticText3; wxStaticText* m_staticText3;
wxChoice* m_choiceGridSize; wxChoice* m_choiceGridSize;
wxStaticText* m_staticGridUnits; wxStaticText* m_staticGridUnits;
wxStaticText* m_staticText51; wxStaticText* m_staticText51;
wxSpinCtrl* m_spinBusWidth; wxSpinCtrl* m_spinBusWidth;
wxStaticText* m_staticBusWidthUnits; wxStaticText* m_staticBusWidthUnits;
wxStaticText* m_staticText5; wxStaticText* m_staticText5;
wxSpinCtrl* m_spinLineWidth; wxSpinCtrl* m_spinLineWidth;
wxStaticText* m_staticLineWidthUnits; wxStaticText* m_staticLineWidthUnits;
wxStaticText* m_staticText7; wxStaticText* m_staticText7;
wxSpinCtrl* m_spinTextSize; wxSpinCtrl* m_spinTextSize;
wxStaticText* m_staticTextSizeUnits; wxStaticText* m_staticTextSizeUnits;
wxStaticText* m_staticText9; wxStaticText* m_staticText9;
wxSpinCtrl* m_spinRepeatHorizontal; wxSpinCtrl* m_spinRepeatHorizontal;
wxStaticText* m_staticRepeatXUnits; wxStaticText* m_staticRepeatXUnits;
wxStaticText* m_staticText12; wxStaticText* m_staticText12;
wxSpinCtrl* m_spinRepeatVertical; wxSpinCtrl* m_spinRepeatVertical;
wxStaticText* m_staticRepeatYUnits; wxStaticText* m_staticRepeatYUnits;
wxStaticText* m_staticText16; wxStaticText* m_staticText16;
wxSpinCtrl* m_spinRepeatLabel; wxSpinCtrl* m_spinRepeatLabel;
wxStaticText* m_staticText221; wxStaticText* m_staticText221;
wxSpinCtrl* m_spinAutoSaveInterval; wxSpinCtrl* m_spinAutoSaveInterval;
wxStaticText* m_staticText23; wxStaticText* m_staticText23;
wxCheckBox* m_checkShowGrid; wxCheckBox* m_checkShowGrid;
wxCheckBox* m_checkShowHiddenPins; wxCheckBox* m_checkShowHiddenPins;
wxCheckBox* m_checkEnableMiddleButtonPan; wxCheckBox* m_checkEnableMiddleButtonPan;
wxCheckBox* m_checkMiddleButtonPanLimited; wxCheckBox* m_checkMiddleButtonPanLimited;
wxCheckBox* m_checkAutoPan; wxCheckBox* m_checkAutoPan;
wxCheckBox* m_checkHVOrientation; wxCheckBox* m_checkHVOrientation;
wxCheckBox* m_checkPageLimits; wxCheckBox* m_checkPageLimits;
wxPanel* m_panel2; wxPanel* m_panel2;
wxStaticText* m_staticText211; wxStaticText* m_staticText211;
wxStaticText* m_staticText15; wxStaticText* m_staticText15;
wxTextCtrl* m_fieldName1; wxTextCtrl* m_fieldName1;
wxStaticText* m_staticText161; wxStaticText* m_staticText161;
wxTextCtrl* m_fieldName2; wxTextCtrl* m_fieldName2;
wxStaticText* m_staticText17; wxStaticText* m_staticText17;
wxTextCtrl* m_fieldName3; wxTextCtrl* m_fieldName3;
wxStaticText* m_staticText18; wxStaticText* m_staticText18;
wxTextCtrl* m_fieldName4; wxTextCtrl* m_fieldName4;
wxStaticText* m_staticText19; wxStaticText* m_staticText19;
wxTextCtrl* m_fieldName5; wxTextCtrl* m_fieldName5;
wxStaticText* m_staticText20; wxStaticText* m_staticText20;
wxTextCtrl* m_fieldName6; wxTextCtrl* m_fieldName6;
wxStaticText* m_staticText21; wxStaticText* m_staticText21;
wxTextCtrl* m_fieldName7; wxTextCtrl* m_fieldName7;
wxStaticText* m_staticText22; wxStaticText* m_staticText22;
wxTextCtrl* m_fieldName8; wxTextCtrl* m_fieldName8;
wxStdDialogButtonSizer* m_sdbSizer1; wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel; wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnChooseUnits( wxCommandEvent& event ) { event.Skip(); } virtual void OnChooseUnits( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMiddleBtnPanEnbl( wxCommandEvent& event ) { event.Skip(); } virtual void OnMiddleBtnPanEnbl( wxCommandEvent& event ) { event.Skip(); }
public: public:
DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EESCHEMA_OPTIONS_BASE(); ~DIALOG_EESCHEMA_OPTIONS_BASE();
}; };
#endif //__DIALOG_EESCHEMA_OPTIONS_BASE_H__ #endif //__DIALOG_EESCHEMA_OPTIONS_BASE_H__
...@@ -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