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 )
{
fn = m_AliasLibNames[ii];
if( !fn.HasExt() ) {
if( !fn.HasExt() )
{
fn.SetExt( FootprintAliasFileExtension );
// above fails if filename have more than one point
}
......@@ -124,8 +125,8 @@ found in the default search paths." ),
msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
SetStatusText( msg, 0 );
m_skipComponentSelect = true;
ii = 0;
BOOST_FOREACH( COMPONENT_INFO& component, m_components )
{
bool found = false;
......@@ -180,4 +181,5 @@ any of the project footprint libraries." ),
}
}
}
m_skipComponentSelect = false;
}
......@@ -280,7 +280,8 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
wxASSERT(Module);
if( GetParent()->m_DisplayFootprintFrame )
{
GetParent()->CreateScreenCmp(); /* refresh general */
// Refresh current selected footprint view:
GetParent()->CreateScreenCmp();
}
if( Module )
......
......@@ -116,6 +116,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
m_isEESchemaNetlist = false;
m_KeepCvpcbOpen = false;
m_undefinedComponentCnt = 0;
m_skipComponentSelect = false;
/* Name of the document footprint list
* usually located in share/modules/footprints_doc
......@@ -406,6 +407,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
if( IsOK( this, _( "Delete selections" ) ) )
{
m_skipComponentSelect = true;
m_ListCmp->SetSelection( 0 );
BOOST_FOREACH( COMPONENT_INFO & component, m_components )
......@@ -414,6 +416,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
SetNewPkg( wxEmptyString );
}
m_skipComponentSelect = false;
m_ListCmp->SetSelection( 0 );
m_undefinedComponentCnt = m_components.size();
}
......@@ -506,18 +509,22 @@ void CVPCB_MAINFRAME::OnLeftDClick( wxListEvent& event )
/* 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 footprint shown in footprint display window (if opened)
*/
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
{
if( m_skipComponentSelect )
return;
#define REDRAW_LIST true
#define SELECT_FULL_LIST true
int selection = -1;
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 );
else
......@@ -553,37 +560,42 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
return;
// Preview of the already assigned footprint.
// Find the footprint that was already choosen for this component and select it.
wxString module = *(&m_components[ selection ].m_Footprint);
// 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.
bool found = false;
for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ )
if( FindFocus() == m_ListCmp )
{
wxString footprintName;
wxString msg = (*m_FootprintList->m_ActiveFootprintList)[ii];
msg.Trim( true );
msg.Trim( false );
footprintName = msg.AfterFirst( wxChar( ' ' ) );
wxString module = *(&m_components[ selection ].m_Footprint);
if( module.Cmp( footprintName ) == 0 )
bool found = false;
for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ )
{
m_FootprintList->SetSelection( ii, true );
found = true;
break;
wxString footprintName;
wxString msg = (*m_FootprintList->m_ActiveFootprintList)[ii];
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 )
{
int ii = m_FootprintList->GetSelection();
if ( ii >= 0 )
m_FootprintList->SetSelection( ii, false );
if( m_DisplayFootprintFrame )
if( ! found )
{
CreateScreenCmp();
int ii = m_FootprintList->GetSelection();
if ( ii >= 0 )
m_FootprintList->SetSelection( ii, false );
if( m_DisplayFootprintFrame )
{
CreateScreenCmp();
}
}
}
SendMessageToEESCHEMA();
DisplayStatus();
}
......
......@@ -46,6 +46,8 @@ protected:
int m_undefinedComponentCnt;
bool m_modified;
bool m_isEESchemaNetlist;
bool m_skipComponentSelect; // true to skip OnSelectComponent event
// (in automatic selection/deletion of associations)
PARAM_CFG_ARRAY m_projectFileParams;
public:
......
......@@ -68,7 +68,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
netList_Reader.m_UseCmpFile = false;
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 );
bool success = netList_Reader.ReadNetList( netfile );
......@@ -79,9 +79,15 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
}
// 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();
for( unsigned ii = 0; ii < cmpInfo.size(); 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.
// Sort components by reference:
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 17 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EESCHEMA_OPTIONS_BASE_H__
#define __DIALOG_EESCHEMA_OPTIONS_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/choice.h>
#include <wx/spinctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/textctrl.h>
#include <wx/notebook.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EESCHEMA_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EESCHEMA_OPTIONS_BASE : public wxDialog
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnChooseUnits( wxCommandEvent& event ){ OnChooseUnits( event ); }
void _wxFB_OnMiddleBtnPanEnbl( wxCommandEvent& event ){ OnMiddleBtnPanEnbl( event ); }
protected:
enum
{
ID_M_SPINAUTOSAVEINTERVAL = 1000,
xwID_ANY
};
wxNotebook* m_notebook1;
wxPanel* m_panel1;
wxStaticText* m_staticText2;
wxChoice* m_choiceUnits;
wxStaticText* m_staticText3;
wxChoice* m_choiceGridSize;
wxStaticText* m_staticGridUnits;
wxStaticText* m_staticText51;
wxSpinCtrl* m_spinBusWidth;
wxStaticText* m_staticBusWidthUnits;
wxStaticText* m_staticText5;
wxSpinCtrl* m_spinLineWidth;
wxStaticText* m_staticLineWidthUnits;
wxStaticText* m_staticText7;
wxSpinCtrl* m_spinTextSize;
wxStaticText* m_staticTextSizeUnits;
wxStaticText* m_staticText9;
wxSpinCtrl* m_spinRepeatHorizontal;
wxStaticText* m_staticRepeatXUnits;
wxStaticText* m_staticText12;
wxSpinCtrl* m_spinRepeatVertical;
wxStaticText* m_staticRepeatYUnits;
wxStaticText* m_staticText16;
wxSpinCtrl* m_spinRepeatLabel;
wxStaticText* m_staticText221;
wxSpinCtrl* m_spinAutoSaveInterval;
wxStaticText* m_staticText23;
wxCheckBox* m_checkShowGrid;
wxCheckBox* m_checkShowHiddenPins;
wxCheckBox* m_checkEnableMiddleButtonPan;
wxCheckBox* m_checkMiddleButtonPanLimited;
wxCheckBox* m_checkAutoPan;
wxCheckBox* m_checkHVOrientation;
wxCheckBox* m_checkPageLimits;
wxPanel* m_panel2;
wxStaticText* m_staticText211;
wxStaticText* m_staticText15;
wxTextCtrl* m_fieldName1;
wxStaticText* m_staticText161;
wxTextCtrl* m_fieldName2;
wxStaticText* m_staticText17;
wxTextCtrl* m_fieldName3;
wxStaticText* m_staticText18;
wxTextCtrl* m_fieldName4;
wxStaticText* m_staticText19;
wxTextCtrl* m_fieldName5;
wxStaticText* m_staticText20;
wxTextCtrl* m_fieldName6;
wxStaticText* m_staticText21;
wxTextCtrl* m_fieldName7;
wxStaticText* m_staticText22;
wxTextCtrl* m_fieldName8;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnChooseUnits( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMiddleBtnPanEnbl( wxCommandEvent& event ) { event.Skip(); }
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();
};
#endif //__DIALOG_EESCHEMA_OPTIONS_BASE_H__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EESCHEMA_OPTIONS_BASE_H__
#define __DIALOG_EESCHEMA_OPTIONS_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/choice.h>
#include <wx/spinctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/textctrl.h>
#include <wx/notebook.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EESCHEMA_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EESCHEMA_OPTIONS_BASE : public wxDialog
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnChooseUnits( wxCommandEvent& event ){ OnChooseUnits( event ); }
void _wxFB_OnMiddleBtnPanEnbl( wxCommandEvent& event ){ OnMiddleBtnPanEnbl( event ); }
protected:
enum
{
ID_M_SPINAUTOSAVEINTERVAL = 1000,
xwID_ANY
};
wxNotebook* m_notebook1;
wxPanel* m_panel1;
wxStaticText* m_staticText2;
wxChoice* m_choiceUnits;
wxStaticText* m_staticText3;
wxChoice* m_choiceGridSize;
wxStaticText* m_staticGridUnits;
wxStaticText* m_staticText51;
wxSpinCtrl* m_spinBusWidth;
wxStaticText* m_staticBusWidthUnits;
wxStaticText* m_staticText5;
wxSpinCtrl* m_spinLineWidth;
wxStaticText* m_staticLineWidthUnits;
wxStaticText* m_staticText7;
wxSpinCtrl* m_spinTextSize;
wxStaticText* m_staticTextSizeUnits;
wxStaticText* m_staticText9;
wxSpinCtrl* m_spinRepeatHorizontal;
wxStaticText* m_staticRepeatXUnits;
wxStaticText* m_staticText12;
wxSpinCtrl* m_spinRepeatVertical;
wxStaticText* m_staticRepeatYUnits;
wxStaticText* m_staticText16;
wxSpinCtrl* m_spinRepeatLabel;
wxStaticText* m_staticText221;
wxSpinCtrl* m_spinAutoSaveInterval;
wxStaticText* m_staticText23;
wxCheckBox* m_checkShowGrid;
wxCheckBox* m_checkShowHiddenPins;
wxCheckBox* m_checkEnableMiddleButtonPan;
wxCheckBox* m_checkMiddleButtonPanLimited;
wxCheckBox* m_checkAutoPan;
wxCheckBox* m_checkHVOrientation;
wxCheckBox* m_checkPageLimits;
wxPanel* m_panel2;
wxStaticText* m_staticText211;
wxStaticText* m_staticText15;
wxTextCtrl* m_fieldName1;
wxStaticText* m_staticText161;
wxTextCtrl* m_fieldName2;
wxStaticText* m_staticText17;
wxTextCtrl* m_fieldName3;
wxStaticText* m_staticText18;
wxTextCtrl* m_fieldName4;
wxStaticText* m_staticText19;
wxTextCtrl* m_fieldName5;
wxStaticText* m_staticText20;
wxTextCtrl* m_fieldName6;
wxStaticText* m_staticText21;
wxTextCtrl* m_fieldName7;
wxStaticText* m_staticText22;
wxTextCtrl* m_fieldName8;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnChooseUnits( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMiddleBtnPanEnbl( wxCommandEvent& event ) { event.Skip(); }
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();
};
#endif //__DIALOG_EESCHEMA_OPTIONS_BASE_H__
......@@ -98,10 +98,10 @@ public:
int m_CntRot180; ///< Automatic placement : cost ( 0..10 )
///< 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
unsigned long m_Link; /* Temporary variable ( used in editions, ...) */
time_t m_Link; // Temporary logical link used in edition
long m_LastEdit_Time;
wxString m_Path;
......
......@@ -935,10 +935,11 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
data = strtok( (char*) data+1, delims );
// 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 );
if( data[1] == 'P' )
if( data && data[1] == 'P' )
module->SetIsPlaced( true );
module->SetPosition( wxPoint( pos_x, pos_y ) );
......@@ -1321,7 +1322,8 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
case 'A': shape = S_ARC; break;
case 'P': shape = S_POLYGON; break;
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 );
}
......
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