Commit f4d5e349 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Fix a bunch of Coverity scan "unhandled exception" errors.

parent 39497b10
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -391,7 +391,7 @@ void FP_LIB_TABLE::Format( OUTPUTFORMATTER* out, int nestLevel ) const




void FP_LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
void FP_LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
    throw( IO_ERROR )
    throw( IO_ERROR, boost::interprocess::lock_exception )
{
{
    out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s))\n",
    out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s))\n",
                out->Quotew( GetNickName() ).c_str(),
                out->Quotew( GetNickName() ).c_str(),
@@ -665,7 +665,7 @@ bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback )




MODULE* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
MODULE* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
    throw( IO_ERROR, PARSE_ERROR )
    throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception )
{
{
    wxString   nickname = aFootprintId.GetLibNickname();
    wxString   nickname = aFootprintId.GetLibNickname();
    wxString   fpname   = aFootprintId.GetFootprintName();
    wxString   fpname   = aFootprintId.GetFootprintName();
+0 −1
Original line number Original line Diff line number Diff line
@@ -179,7 +179,6 @@ class COMPONENTS_LISTBOX : public ITEMS_LISTBOX_BASE
{
{
public:
public:
    wxArrayString      m_ComponentList;
    wxArrayString      m_ComponentList;
    CVPCB_MAINFRAME*   m_Parent;


public:
public:


+4 −3
Original line number Original line Diff line number Diff line
@@ -756,7 +756,7 @@ bool PART_LIB::SaveHeader( OUTPUTFORMATTER& aFormatter )
}
}




PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) throw( IO_ERROR )
PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) throw( IO_ERROR, boost::bad_pointer )
{
{
    std::auto_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
    std::auto_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );


@@ -784,7 +784,7 @@ PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) throw( IO_ERROR )
}
}




PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName ) throw( IO_ERROR )
PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName ) throw( IO_ERROR, boost::bad_pointer )
{
{
    PART_LIB* lib;
    PART_LIB* lib;


@@ -979,7 +979,8 @@ void PART_LIBS::RemoveCacheLibrary()




void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
        wxString* aPaths, wxArrayString* aNames ) throw( IO_ERROR )
                                  wxString* aPaths, wxArrayString* aNames )
    throw( IO_ERROR, boost::bad_pointer )
{
{
    wxString pro = aProject->GetProjectFullName();
    wxString pro = aProject->GetProjectFullName();


+4 −3
Original line number Original line Diff line number Diff line
@@ -123,7 +123,7 @@ public:
     * @param aFileName - File name object of part library.
     * @param aFileName - File name object of part library.
     * @throw IO_ERROR if there's any problem loading.
     * @throw IO_ERROR if there's any problem loading.
     */
     */
    PART_LIB* AddLibrary( const wxString& aFileName ) throw( IO_ERROR );
    PART_LIB* AddLibrary( const wxString& aFileName ) throw( IO_ERROR, boost::bad_pointer );


    /**
    /**
     * Function AddLibrary
     * Function AddLibrary
@@ -160,7 +160,8 @@ public:
     * (without paths).
     * (without paths).
     */
     */
    static void LibNamesAndPaths( PROJECT* aProject, bool doSave,
    static void LibNamesAndPaths( PROJECT* aProject, bool doSave,
            wxString* aPaths, wxArrayString* aNames=NULL ) throw( IO_ERROR );
                                  wxString* aPaths, wxArrayString* aNames=NULL )
        throw( IO_ERROR, boost::bad_pointer );


    /**
    /**
     * Function cacheName
     * Function cacheName
@@ -545,7 +546,7 @@ public:
     *   the caller.
     *   the caller.
     * @throw IO_ERROR if there's any problem loading the library.
     * @throw IO_ERROR if there's any problem loading the library.
     */
     */
    static PART_LIB* LoadLibrary( const wxString& aFileName ) throw( IO_ERROR );
    static PART_LIB* LoadLibrary( const wxString& aFileName ) throw( IO_ERROR, boost::bad_pointer );
};
};




+63 −63
Original line number Original line Diff line number Diff line
@@ -70,7 +70,7 @@ private:
    friend class SCH_EDIT_FRAME;
    friend class SCH_EDIT_FRAME;


    SCH_EDIT_FRAME* m_Parent;
    SCH_EDIT_FRAME* m_Parent;
    SCH_COMPONENT*  m_Cmp;
    SCH_COMPONENT*  m_cmp;
    LIB_PART*       m_part;
    LIB_PART*       m_part;
    bool            m_skipCopyFromPanel;
    bool            m_skipCopyFromPanel;


@@ -169,6 +169,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
{
{
    m_Parent = (SCH_EDIT_FRAME*) parent;
    m_Parent = (SCH_EDIT_FRAME*) parent;


    m_cmp = NULL;
    m_part = NULL;
    m_part = NULL;
    m_skipCopyFromPanel = false;
    m_skipCopyFromPanel = false;


@@ -301,7 +302,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
    wxString newname = chipnameTextCtrl->GetValue();
    wxString newname = chipnameTextCtrl->GetValue();


    // Save current flags which could be modified by next change settings
    // Save current flags which could be modified by next change settings
    STATUS_FLAGS flags = m_Cmp->GetFlags();
    STATUS_FLAGS flags = m_cmp->GetFlags();


    newname.Replace( wxT( " " ), wxT( "_" ) );
    newname.Replace( wxT( " " ), wxT( "_" ) );


@@ -309,7 +310,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
    {
    {
        DisplayError( NULL, _( "No Component Name!" ) );
        DisplayError( NULL, _( "No Component Name!" ) );
    }
    }
    else if( Cmp_KEEPCASE( newname, m_Cmp->m_part_name ) )
    else if( Cmp_KEEPCASE( newname, m_cmp->m_part_name ) )
    {
    {
        PART_LIBS* libs = Prj().SchLibs();
        PART_LIBS* libs = Prj().SchLibs();


@@ -321,41 +322,41 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
        }
        }
        else    // Change component from lib!
        else    // Change component from lib!
        {
        {
            m_Cmp->SetPartName( newname, libs );
            m_cmp->SetPartName( newname, libs );
        }
        }
    }
    }


    // For components with multiple shapes (De Morgan representation) Set the selected shape:
    // For components with multiple shapes (De Morgan representation) Set the selected shape:
    if( convertCheckBox->IsEnabled() )
    if( convertCheckBox->IsEnabled() )
    {
    {
        m_Cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
        m_cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
    }
    }


    //Set the part selection in multiple part per package
    //Set the part selection in multiple part per package
    if( m_Cmp->GetUnit() )
    if( m_cmp->GetUnit() )
    {
    {
        int unit_selection = unitChoice->GetCurrentSelection() + 1;
        int unit_selection = unitChoice->GetCurrentSelection() + 1;


        m_Cmp->SetUnitSelection( &m_Parent->GetCurrentSheet(), unit_selection );
        m_cmp->SetUnitSelection( &m_Parent->GetCurrentSheet(), unit_selection );
        m_Cmp->SetUnit( unit_selection );
        m_cmp->SetUnit( unit_selection );
    }
    }


    switch( orientationRadioBox->GetSelection() )
    switch( orientationRadioBox->GetSelection() )
    {
    {
    case 0:
    case 0:
        m_Cmp->SetOrientation( CMP_ORIENT_0 );
        m_cmp->SetOrientation( CMP_ORIENT_0 );
        break;
        break;


    case 1:
    case 1:
        m_Cmp->SetOrientation( CMP_ORIENT_90 );
        m_cmp->SetOrientation( CMP_ORIENT_90 );
        break;
        break;


    case 2:
    case 2:
        m_Cmp->SetOrientation( CMP_ORIENT_180 );
        m_cmp->SetOrientation( CMP_ORIENT_180 );
        break;
        break;


    case 3:
    case 3:
        m_Cmp->SetOrientation( CMP_ORIENT_270 );
        m_cmp->SetOrientation( CMP_ORIENT_270 );
        break;
        break;
    }
    }


@@ -367,17 +368,17 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
        break;
        break;


    case 1:
    case 1:
        m_Cmp->SetOrientation( CMP_MIRROR_X );
        m_cmp->SetOrientation( CMP_MIRROR_X );
        break;
        break;


    case 2:
    case 2:
        m_Cmp->SetOrientation( CMP_MIRROR_Y );
        m_cmp->SetOrientation( CMP_MIRROR_Y );
        break;
        break;
    }
    }


    // Restore m_Flag modified by SetUnit() and other change settings
    // Restore m_Flag modified by SetUnit() and other change settings
    m_Cmp->ClearFlags();
    m_cmp->ClearFlags();
    m_Cmp->SetFlags( flags );
    m_cmp->SetFlags( flags );
}
}




@@ -396,9 +397,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event


    // save old cmp in undo list if not already in edit, or moving ...
    // save old cmp in undo list if not already in edit, or moving ...
    // or the component to be edited is part of a block
    // or the component to be edited is part of a block
    if( m_Cmp->m_Flags == 0 ||
    if( m_cmp->m_Flags == 0
        m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
      || m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
        m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
        m_Parent->SaveCopyInUndoList( m_cmp, UR_CHANGED );


    copyPanelToOptions();
    copyPanelToOptions();


@@ -441,21 +442,21 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
    // change all field positions from relative to absolute
    // change all field positions from relative to absolute
    for( unsigned i = 0;  i<m_FieldsBuf.size();  ++i )
    for( unsigned i = 0;  i<m_FieldsBuf.size();  ++i )
    {
    {
        m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_Cmp->m_Pos );
        m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_cmp->m_Pos );
    }
    }


    LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name );
    LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_cmp->m_part_name );


    if( entry && entry->IsPower() )
    if( entry && entry->IsPower() )
        m_FieldsBuf[VALUE].SetText( m_Cmp->m_part_name );
        m_FieldsBuf[VALUE].SetText( m_cmp->m_part_name );


    // copy all the fields back, and change the length of m_Fields.
    // copy all the fields back, and change the length of m_Fields.
    m_Cmp->SetFields( m_FieldsBuf );
    m_cmp->SetFields( m_FieldsBuf );


    // Reference has a specific initialization, depending on the current active sheet
    // Reference has a specific initialization, depending on the current active sheet
    // because for a given component, in a complex hierarchy, there are more than one
    // because for a given component, in a complex hierarchy, there are more than one
    // reference.
    // reference.
    m_Cmp->SetRef( &m_Parent->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() );
    m_cmp->SetRef( &m_Parent->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() );


    m_Parent->OnModify();
    m_Parent->OnModify();
    m_Parent->GetScreen()->TestDanglingEnds();
    m_Parent->GetScreen()->TestDanglingEnds();
@@ -474,7 +475,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&


    unsigned  fieldNdx = m_FieldsBuf.size();
    unsigned  fieldNdx = m_FieldsBuf.size();


    SCH_FIELD blank( wxPoint(), fieldNdx, m_Cmp );
    SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp );


    blank.SetOrientation( m_FieldsBuf[REFERENCE].GetOrientation() );
    blank.SetOrientation( m_FieldsBuf[REFERENCE].GetOrientation() );


@@ -621,7 +622,7 @@ SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aField


void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent )
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent )
{
{
    m_Cmp = aComponent;
    m_cmp = aComponent;


    /*  We have 3 component related field lists to be aware of: 1) UI
    /*  We have 3 component related field lists to be aware of: 1) UI
        presentation, 2) fields in component ram copy, and 3) fields recorded
        presentation, 2) fields in component ram copy, and 3) fields recorded
@@ -635,7 +636,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
        which came from the component.
        which came from the component.
    */
    */


    m_part = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name );
    m_part = Prj().SchLibs()->FindLibPart( m_cmp->m_part_name );


#if 0 && defined(DEBUG)
#if 0 && defined(DEBUG)
    for( int i = 0;  i<aComponent->GetFieldCount();  ++i )
    for( int i = 0;  i<aComponent->GetFieldCount();  ++i )
@@ -658,7 +659,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
        m_FieldsBuf.push_back(  aComponent->m_Fields[i] );
        m_FieldsBuf.push_back(  aComponent->m_Fields[i] );


        // make the editable field position relative to the component
        // make the editable field position relative to the component
        m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_Cmp->m_Pos );
        m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_cmp->m_Pos );
    }
    }


    // Add template fieldnames:
    // Add template fieldnames:
@@ -669,7 +670,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
    for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin();  it!=tfnames.end();  ++it )
    for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin();  it!=tfnames.end();  ++it )
    {
    {
        // add a new field unconditionally to the UI only
        // add a new field unconditionally to the UI only
        SCH_FIELD   fld( wxPoint(0,0), -1 /* id is a relic */, m_Cmp, it->m_Name );
        SCH_FIELD   fld( wxPoint(0,0), -1 /* id is a relic */, m_cmp, it->m_Name );


        // See if field by same name already exists in component.
        // See if field by same name already exists in component.
        SCH_FIELD* schField = aComponent->FindField( it->m_Name );
        SCH_FIELD* schField = aComponent->FindField( it->m_Name );
@@ -691,7 +692,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
            fld = *schField;
            fld = *schField;


            // make the editable field position relative to the component
            // make the editable field position relative to the component
            fld.SetTextPosition( fld.GetTextPosition() - m_Cmp->m_Pos );
            fld.SetTextPosition( fld.GetTextPosition() - m_cmp->m_Pos );
        }
        }


        m_FieldsBuf.push_back( fld );
        m_FieldsBuf.push_back( fld );
@@ -711,7 +712,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent


            // make the editable field position relative to the component
            // make the editable field position relative to the component
            m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() -
            m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() -
                                                 m_Cmp->m_Pos );
                                                 m_cmp->m_Pos );
        }
        }
    }
    }


@@ -724,7 +725,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
    }
    }
#endif
#endif


    m_FieldsBuf[REFERENCE].SetText( m_Cmp->GetRef( &m_Parent->GetCurrentSheet() ) );
    m_FieldsBuf[REFERENCE].SetText( m_cmp->GetRef( &m_Parent->GetCurrentSheet() ) );


    for( unsigned i = 0;  i<m_FieldsBuf.size();  ++i )
    for( unsigned i = 0;  i<m_FieldsBuf.size();  ++i )
    {
    {
@@ -744,7 +745,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent


    // disable some options inside the edit dialog
    // disable some options inside the edit dialog
    // which can cause problems while dragging
    // which can cause problems while dragging
    if( m_Cmp->IsDragging() )
    if( m_cmp->IsDragging() )
    {
    {
        orientationRadioBox->Disable();
        orientationRadioBox->Disable();
        mirrorRadioBox->Disable();
        mirrorRadioBox->Disable();
@@ -855,7 +856,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
    textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
    textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );


    wxPoint coord = field.GetTextPosition();
    wxPoint coord = field.GetTextPosition();
    wxPoint zero  = -m_Cmp->m_Pos;  // relative zero
    wxPoint zero  = -m_cmp->m_Pos;  // relative zero


    // If the field value is empty and the position is at relative zero, we
    // If the field value is empty and the position is at relative zero, we
    // set the initial position as a small offset from the ref field, and
    // set the initial position as a small offset from the ref field, and
@@ -965,11 +966,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
    }
    }


    // For components with multiple parts per package, set the unit selection
    // For components with multiple parts per package, set the unit selection
    if( m_Cmp->GetUnit() <= (int)unitChoice->GetCount() )
    if( m_cmp->GetUnit() <= (int)unitChoice->GetCount() )
        unitChoice->SetSelection( m_Cmp->GetUnit() - 1 );
        unitChoice->SetSelection( m_cmp->GetUnit() - 1 );


    // Disable unit selection if only one unit exists:
    // Disable unit selection if only one unit exists:
    if( m_Cmp->GetUnit() <= 1 )
    if( m_cmp->GetUnit() <= 1 )
    {
    {
        unitChoice->Enable( false );
        unitChoice->Enable( false );
        unitsInterchageableLabel->Show( false );
        unitsInterchageableLabel->Show( false );
@@ -984,7 +985,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
            unitsInterchageableLabel->SetLabel( _( "No" ) );
            unitsInterchageableLabel->SetLabel( _( "No" ) );
    }
    }


    int orientation = m_Cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y );
    int orientation = m_cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y );


    if( orientation == CMP_ORIENT_90 )
    if( orientation == CMP_ORIENT_90 )
        orientationRadioBox->SetSelection( 1 );
        orientationRadioBox->SetSelection( 1 );
@@ -995,7 +996,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
    else
    else
        orientationRadioBox->SetSelection( 0 );
        orientationRadioBox->SetSelection( 0 );


    int mirror = m_Cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
    int mirror = m_cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );


    if( mirror == CMP_MIRROR_X )
    if( mirror == CMP_MIRROR_X )
    {
    {
@@ -1012,38 +1013,37 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()


    // Activate/Desactivate the normal/convert option ? (activated only if
    // Activate/Desactivate the normal/convert option ? (activated only if
    // the component has more than one shape)
    // the component has more than one shape)
    if( m_Cmp->GetConvert() > 1 )
    if( m_cmp->GetConvert() > 1 )
        convertCheckBox->SetValue( true );
        convertCheckBox->SetValue( true );


    if( m_part == NULL || !m_part->HasConversion() )
    if( m_part == NULL || !m_part->HasConversion() )
        convertCheckBox->Enable( false );
        convertCheckBox->Enable( false );


    // Set the component's library name.
    // Set the component's library name.
    chipnameTextCtrl->SetValue( m_Cmp->m_part_name );
    chipnameTextCtrl->SetValue( m_cmp->m_part_name );


    // Set the component's unique ID time stamp.
    // Set the component's unique ID time stamp.
    m_textCtrlTimeStamp->SetValue( wxString::Format( wxT( "%8.8lX" ),
    m_textCtrlTimeStamp->SetValue( wxString::Format( wxT( "%8.8lX" ),
                                   (unsigned long) m_Cmp->GetTimeStamp() ) );
                                   (unsigned long) m_cmp->GetTimeStamp() ) );
}
}




#include <kicad_device_context.h>
#include <kicad_device_context.h>


/* reinitialize components parameters to default values found in lib

 */
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
{
{
    if( !m_Cmp )
    if( !m_cmp )
        return;
        return;


    if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name ) )
    if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_cmp->m_part_name ) )
    {
    {
        // save old cmp in undo list if not already in edit, or moving ...
        // save old cmp in undo list if not already in edit, or moving ...
        if( m_Cmp->m_Flags == 0 )
        if( m_cmp->m_Flags == 0 )
            m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
            m_Parent->SaveCopyInUndoList( m_cmp, UR_CHANGED );


        INSTALL_UNBUFFERED_DC( dc, m_Parent->GetCanvas() );
        INSTALL_UNBUFFERED_DC( dc, m_Parent->GetCanvas() );
        m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
        m_cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );


        // Initialize fixed field values to default values found in library
        // Initialize fixed field values to default values found in library
        // Note: the field texts are not modified because they are set in schematic,
        // Note: the field texts are not modified because they are set in schematic,
@@ -1051,35 +1051,35 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
        // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
        // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
        LIB_FIELD& refField = part->GetReferenceField();
        LIB_FIELD& refField = part->GetReferenceField();


        m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
        m_cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_cmp->m_Pos );
        m_Cmp->GetField( REFERENCE )->ImportValues( refField );
        m_cmp->GetField( REFERENCE )->ImportValues( refField );


        LIB_FIELD& valField = part->GetValueField();
        LIB_FIELD& valField = part->GetValueField();


        m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
        m_cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_cmp->m_Pos );
        m_Cmp->GetField( VALUE )->ImportValues( valField );
        m_cmp->GetField( VALUE )->ImportValues( valField );


        LIB_FIELD* field = part->GetField(FOOTPRINT);
        LIB_FIELD* field = part->GetField(FOOTPRINT);


        if( field && m_Cmp->GetField( FOOTPRINT ) )
        if( field && m_cmp->GetField( FOOTPRINT ) )
        {
        {
            m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
            m_cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_cmp->m_Pos );
            m_Cmp->GetField( FOOTPRINT )->ImportValues( *field );
            m_cmp->GetField( FOOTPRINT )->ImportValues( *field );
        }
        }


        field = part->GetField(DATASHEET);
        field = part->GetField(DATASHEET);


        if( field && m_Cmp->GetField( DATASHEET ) )
        if( field && m_cmp->GetField( DATASHEET ) )
        {
        {
            m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
            m_cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_cmp->m_Pos );
            m_Cmp->GetField( DATASHEET )->ImportValues( *field );
            m_cmp->GetField( DATASHEET )->ImportValues( *field );
        }
        }


        m_Cmp->SetOrientation( CMP_NORMAL );
        m_cmp->SetOrientation( CMP_NORMAL );


        m_Parent->OnModify();
        m_Parent->OnModify();


        m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
        m_cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );


        EndQuasiModal( wxID_OK );
        EndQuasiModal( wxID_OK );
    }
    }
Loading