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

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
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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;
}
+2 −1
Original line number Diff line number Diff line
@@ -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 )
+36 −24
Original line number Diff line number Diff line
@@ -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,7 +560,12 @@ 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.
    // 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);

        bool found = false;
@@ -582,7 +594,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
                CreateScreenCmp();
            }
        }

    }

    SendMessageToEESCHEMA();
    DisplayStatus();
+2 −0
Original line number Diff line number Diff line
@@ -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:
+7 −1
Original line number Diff line number Diff line
@@ -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:
Loading