Commit 44e588dc authored by stambaughw's avatar stambaughw

Fix bug in LocatePinByNumber that could cause EESchema to crash.

parent 0a75c624
...@@ -615,16 +615,18 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1, ...@@ -615,16 +615,18 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
/** /**
* Find a PIN in a component * Find a PIN in a component by pin number.
* @param pin_number = pin number (string) *
* @param pin_number = pin number (string) * @param ePin_Number - pin number to locate.
* @return a pointer on the pin, or NULL if not found * @param eComponent - schematic component object to search.
*
* @return a pointer to the located the pin, or NULL if not found
*/ */
LIB_PIN* LocatePinByNumber( const wxString& ePin_Number, LIB_PIN* LocatePinByNumber( const wxString& ePin_Number,
SCH_COMPONENT* eComponent ) SCH_COMPONENT* eComponent )
{ {
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LIB_PIN* Pin; LIB_PIN_LIST pinList;
int Unit, Convert; int Unit, Convert;
Entry = CMP_LIBRARY::FindLibraryComponent( eComponent->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( eComponent->m_ChipName );
...@@ -637,22 +639,17 @@ LIB_PIN* LocatePinByNumber( const wxString& ePin_Number, ...@@ -637,22 +639,17 @@ LIB_PIN* LocatePinByNumber( const wxString& ePin_Number,
Unit = eComponent->m_Multi; Unit = eComponent->m_Multi;
Convert = eComponent->m_Convert; Convert = eComponent->m_Convert;
for( Pin = Entry->GetNextPin(); Pin != NULL; Entry->GetPins( pinList, Unit, Convert );
Pin = Entry->GetNextPin( Pin ) )
{
wxASSERT( Pin->Type() != COMPONENT_PIN_DRAW_TYPE );
if( Unit && Pin->m_Unit && ( Pin->m_Unit != Unit ) )
continue;
if( Convert && Pin->m_Convert && ( Pin->m_Convert != Convert ) ) for( size_t i = 0; i < pinList.size(); i++ )
continue; {
wxASSERT( pinList[i]->Type() == COMPONENT_PIN_DRAW_TYPE );
wxString pNumber; wxString pNumber;
Pin->ReturnPinStringNum( pNumber ); pinList[i]->ReturnPinStringNum( pNumber );
if( ePin_Number == pNumber ) if( ePin_Number == pNumber )
return Pin; return pinList[i];
} }
return NULL; return NULL;
......
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