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

Eeschema: Fix Bug #1404118 (Schematic Editor Option Seg Fault in Template Field Names)

parents 6deb3823 43013cec
Loading
Loading
Loading
Loading
+49 −50
Original line number Diff line number Diff line
@@ -8,56 +8,55 @@
static const unsigned char png[] = {
 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c,
 0xce, 0x00, 0x00, 0x03, 0x07, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xbd, 0x95, 0x5d, 0x48, 0x53,
 0x61, 0x18, 0xc7, 0x9f, 0xb5, 0x1d, 0x3f, 0xe6, 0x4a, 0x66, 0xb0, 0x66, 0xa4, 0xcb, 0xbc, 0x68,
 0x05, 0xae, 0xd2, 0x44, 0xa6, 0x4e, 0x96, 0x0c, 0x6a, 0xce, 0xd6, 0x3e, 0x5d, 0xdb, 0xdc, 0x9c,
 0x9a, 0x4b, 0x23, 0xfa, 0xa0, 0x30, 0x8a, 0x3e, 0x84, 0x8a, 0x88, 0x02, 0xbb, 0xe8, 0x26, 0x88,
 0xd0, 0x8b, 0x22, 0x02, 0xa3, 0x8b, 0x02, 0x6f, 0x84, 0x6e, 0xa3, 0x14, 0xea, 0x2e, 0x84, 0xb0,
 0x8b, 0xa0, 0xbc, 0xd2, 0x20, 0xa2, 0x4c, 0x4f, 0xff, 0xe7, 0x74, 0x66, 0x4b, 0x2c, 0x3c, 0xc7,
 0xd1, 0x19, 0x3f, 0xce, 0x7b, 0x9e, 0x1d, 0x9e, 0x1f, 0xcf, 0xfb, 0x3e, 0xef, 0x7b, 0x48, 0x14,
 0x45, 0xfa, 0x1f, 0x2c, 0x1b, 0x3c, 0x92, 0x22, 0x73, 0x5f, 0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5b, 0xe8, 0xf1, 0xe1, 0xe3, 0x3b,
 0x24, 0xbc, 0x89, 0x55, 0x9b, 0xcd, 0x36, 0x53, 0x57, 0x57, 0x97, 0x8d, 0x44, 0x22, 0x0e, 0x8e,
 0x4b, 0x92, 0xf4, 0x9a, 0xe3, 0x65, 0x65, 0x65, 0x6f, 0xa2, 0xd1, 0xe8, 0x12, 0x8e, 0xd9, 0xed,
 0x76, 0x3e, 0x2f, 0x55, 0x97, 0xcb, 0x35, 0xd5, 0xd4, 0xd4, 0x54, 0x6f, 0xaa, 0x7c, 0x54, 0xb2,
 0x19, 0x49, 0xa7, 0x9d, 0x4e, 0xe7, 0x6c, 0x2c, 0x16, 0x1b, 0x56, 0x14, 0xa5, 0x80, 0xbf, 0x16,
 0xc9, 0x5e, 0x70, 0xd2, 0xf2, 0xf2, 0xf2, 0xa9, 0x64, 0x32, 0xb9, 0x9b, 0x63, 0x18, 0xd3, 0xc8,
 0xc7, 0x57, 0x51, 0x51, 0xd1, 0x4c, 0x3c, 0x1e, 0xbf, 0x4f, 0x26, 0x0f, 0x46, 0x5b, 0x28, 0x14,
 0x0a, 0xe3, 0xab, 0xef, 0xa0, 0x75, 0x7b, 0xf5, 0xf6, 0xe1, 0xee, 0xae, 0xa9, 0xa9, 0xe9, 0x45,
 0xc2, 0x1e, 0x7e, 0xe6, 0x18, 0xcb, 0xc2, 0xe1, 0x70, 0x1c, 0x1f, 0x74, 0x1b, 0xf2, 0x1d, 0xe6,
 0x27, 0x15, 0xb2, 0x4c, 0x26, 0x23, 0x73, 0x22, 0x63, 0x9c, 0xdb, 0xa8, 0xb7, 0x52, 0x87, 0xc7,
 0xe8, 0x63, 0x7f, 0x00, 0x56, 0xb3, 0x98, 0x72, 0xf8, 0x9a, 0x02, 0x50, 0x00, 0x00, 0x00, 0x00,
 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
};

const BITMAP_OPAQUE gl_change_xpm[1] = {{ png, sizeof( png ), "gl_change_xpm" }};
+80 −53
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
    DIALOG_EESCHEMA_OPTIONS_BASE( parent )
{
    m_choiceUnits->SetFocus();
    m_sdbSizer1OK->SetDefault();
    m_sdbSizerOK->SetDefault();

    // Dialog should not shrink beyond it's minimal size.
    GetSizer()->SetSizeHints( this );
@@ -62,14 +62,11 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
    templateFieldListCtrl->SetColumnWidth( 1, templateFieldListCtrl->GetSize().GetWidth() / 3.5 );
    templateFieldListCtrl->SetColumnWidth( 2, templateFieldListCtrl->GetSize().GetWidth() / 3.5 );

    // Invalid field selected and don't ignore selection events because
    // they'll be from the user
    selectedField = 0;
    selectionValid = false;
    ignoreSelection = false;
    // Invalid field selected
    selectedField = -1;

    // Make sure we select the first tab of the options tab page
    m_notebook1->SetSelection( 0 );
    m_notebook->SetSelection( 0 );

    // Connect the edit controls for the template field names to the kill focus event which
    // doesn't propogate, hence the need to connect it here.
@@ -79,9 +76,6 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :

    fieldDefaultValueTextCtrl->Connect( wxEVT_KILL_FOCUS,
            wxFocusEventHandler( DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus ), NULL, this );

    fieldVisibleCheckbox->Connect( wxEVT_KILL_FOCUS,
            wxFocusEventHandler( DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus ), NULL, this );
}


@@ -169,34 +163,57 @@ void DIALOG_EESCHEMA_OPTIONS::SetGridSizes( const GRIDS& aGridSizes, int aGridId

void DIALOG_EESCHEMA_OPTIONS::RefreshTemplateFieldView( void )
{
    // Delete all items in the template field list control and add all of the
    // current template fields
    templateFieldListCtrl->DeleteAllItems();
    // Loop through the template fieldnames and add them to the list control
    // or just change texts if room exists
    long itemindex = 0;
    wxString tmp;

    // Loop through the template fieldnames and add then to the list control
    for( TEMPLATE_FIELDNAMES::iterator fld = templateFields.begin();
            fld != templateFields.end(); ++fld )
            fld != templateFields.end(); ++fld, itemindex++ )
    {
        long itemindex = templateFieldListCtrl->InsertItem(
        if( templateFieldListCtrl->GetItemCount() <= itemindex )
        {
            templateFieldListCtrl->InsertItem(
                templateFieldListCtrl->GetItemCount(), fld->m_Name );
        }

        wxListItem litem;
        litem.SetId( itemindex );
        templateFieldListCtrl->GetItem( litem );

        litem.SetColumn( 0 );
        if( litem.GetText() != fld->m_Name )
            templateFieldListCtrl->SetItem( itemindex, 0, fld->m_Name );

        litem.SetColumn( 1 );
        if( litem.GetText() != fld->m_Value )
            templateFieldListCtrl->SetItem( itemindex, 1, fld->m_Value );

        templateFieldListCtrl->SetItem( itemindex, 2,
                ( fld->m_Visible == true ) ? _( "Visible" ) : _( "Hidden" ) );
        tmp = ( fld->m_Visible == true ) ? _( "Visible" ) : _( "Hidden" );

        litem.SetColumn( 2 );
        if(  litem.GetText() != tmp )
            templateFieldListCtrl->SetItem( itemindex, 2, tmp );
    }

    // Remove extra items:
    while( templateFieldListCtrl->GetItemCount() > itemindex )
    {
        templateFieldListCtrl->DeleteItem( itemindex );
    }

}


void DIALOG_EESCHEMA_OPTIONS::SelectTemplateField( int aItem )
{
    // Only select valid items!
    if( !selectionValid || ( aItem >= templateFieldListCtrl->GetItemCount() ) )
    if( ( aItem < 0 ) || ( aItem >= templateFieldListCtrl->GetItemCount() ) )
        return;

    // Make sure we select the new item
    ignoreSelection = true;
    templateFieldListCtrl->SetItemState( aItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
    // Make sure we select the new item in list control
    if( templateFieldListCtrl->GetFirstSelected() != aItem )
        templateFieldListCtrl->Select( aItem, true );
}


@@ -204,7 +221,7 @@ void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
{
    // If there is currently a valid selection, copy the edit panel to the
    // selected field so as not to lose the data
    if( selectionValid && ( selectedField < templateFields.size() ) )
    if( fieldSelectionValid( selectedField ) )
        copyPanelToSelected();

    // Add a new fieldname to the fieldname list
@@ -217,7 +234,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
    // Make sure any previously selected state is cleared and then select the
    // new field
    selectedField = templateFields.size() - 1;
    selectionValid = true;

    // Update the display to reflect the new data
    RefreshTemplateFieldView();
@@ -234,7 +250,7 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )
{
    // If there is currently a valid selection, delete the template field from
    // the template field list
    if( selectionValid && ( selectedField < templateFields.size() ) )
    if( fieldSelectionValid( selectedField ) )
    {
        // Delete the fieldname from the fieldname list
        templateFields.erase( templateFields.begin() + selectedField );
@@ -247,18 +263,18 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )

        // Update the display to reflect the new data
        RefreshTemplateFieldView();

        copySelectedToPanel();

        // Make sure after the refresh that the selected item is correct
        SelectTemplateField( selectedField );
    }

    event.Skip();
}


void DIALOG_EESCHEMA_OPTIONS::copyPanelToSelected( void )
{
    if( !selectionValid || ( selectedField >= templateFields.size() ) )
    if( !fieldSelectionValid( selectedField ) )
        return;

    // Update the template field from the edit panel
@@ -278,10 +294,33 @@ void DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus( wxFocusEvent& event )
    event.Skip();
}

void DIALOG_EESCHEMA_OPTIONS::OnEnterKey( wxCommandEvent& event )
{
    // Process the event produced when the user presses enter key
    // in template fieldname text control or template fieldvalue text control
    // Validate the current name or value, and switch focus to the other param
    // (value or name)
    copyPanelToSelected();
    RefreshTemplateFieldView();

    if( fieldNameTextCtrl->HasFocus() )
        fieldDefaultValueTextCtrl->SetFocus();
    else
        fieldNameTextCtrl->SetFocus();
}


void DIALOG_EESCHEMA_OPTIONS::OnVisibleFieldClick( wxCommandEvent& event )
{
    // Process the event produced when the user click on
    // the check box which controls the field visibility
    copyPanelToSelected();
    RefreshTemplateFieldView();
}

void DIALOG_EESCHEMA_OPTIONS::copySelectedToPanel( void )
{
    if( !selectionValid || ( selectedField >= templateFields.size() ) )
    if( !fieldSelectionValid( selectedField ) )
        return;

    // Update the panel data from the selected template field
@@ -293,35 +332,13 @@ void DIALOG_EESCHEMA_OPTIONS::copySelectedToPanel( void )

void DIALOG_EESCHEMA_OPTIONS::OnTemplateFieldSelected( wxListEvent& event )
{
    // If the class has generated the event and asked to ignore it, honour that and reset the
    // ignore flag for the next user event.
    if( ignoreSelection )
    {
        ignoreSelection = false;
        event.Skip();
        return;
    }

    // Before getting the new field data, make sure we save the old!
    copyPanelToSelected();

    // Now update the selected field and copy the data from the field to the
    // edit panel
    selectedField = event.GetIndex();
    selectionValid = true;
    copySelectedToPanel();

    // Refresh the template field view - this deletes all fields and then
    // re-fills the entire data grid. It then re-selects the currently
    // selected field. This will be recursive, so disable this event while
    // we refresh the view
    RefreshTemplateFieldView();

    // If an item was selected, make sure we re-select it, or at least the
    // same position in the grid
    SelectTemplateField( selectedField );

    event.Skip();
}


@@ -330,8 +347,18 @@ void DIALOG_EESCHEMA_OPTIONS::SetTemplateFields( const TEMPLATE_FIELDNAMES& aFie
    // Set the template fields object
    templateFields = aFields;

    // Refresh the view
    // select the last field ( will set selectedField to -1 if no field ):
    selectedField = templateFields.size()-1;

    // Build and refresh the view
    RefreshTemplateFieldView();

    if( selectedField >= 0 )
    {
        copySelectedToPanel();
        SelectTemplateField( selectedField );
    }

}


+22 −7
Original line number Diff line number Diff line
@@ -41,15 +41,31 @@ protected:
    TEMPLATE_FIELDNAMES templateFields;

    /** @brief The current row selected in the template fieldname wxListCtrl which is also in the
        edit panel */
     * edit panel
     * selectedField = -1 when no valid item selected
     */
    size_t selectedField;

    /** @brief The selectedField value is only valid when this bool is set to true */
    bool selectionValid;
    /** @brief return true if aFieldId is a valid field selection
     */
    bool fieldSelectionValid( size_t aFieldId )
    {
        return ( aFieldId >= 0 ) && ( aFieldId < templateFields.size() );
    }

    /**
     * Function OnEnterKey (virtual)
     * Process the wxWidgets @a event produced when the user presses enter key
     * in template fieldname text control or template fieldvalue text control
     */
    void OnEnterKey( wxCommandEvent& event );

    /** @brief Set to true internally when OnTemplateFieldSelected() an event needs to be
        ignored */
    bool ignoreSelection;
    /**
     * Function OnVisibleFieldClick (virtual)
     * Process the wxWidgets @a event produced when the user click on
     * the check box which controls the field visibility
     */
	void OnVisibleFieldClick( wxCommandEvent& event );

    /**
     * Function OnAddButtonClick
@@ -60,7 +76,6 @@ protected:
     *
     * Adds a new template fieldname (with default values) to the template fieldnames data
     */

    void OnAddButtonClick( wxCommandEvent& event );

    /**
+21 −18
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun  6 2014)
// C++ code generated with wxFormBuilder (version Jun  5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -15,6 +15,9 @@ BEGIN_EVENT_TABLE( DIALOG_EESCHEMA_OPTIONS_BASE, DIALOG_SHIM )
	EVT_CHECKBOX( xwID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnMiddleBtnPanEnbl )
	EVT_LIST_ITEM_DESELECTED( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnTemplateFieldDeselected )
	EVT_LIST_ITEM_SELECTED( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnTemplateFieldSelected )
	EVT_TEXT_ENTER( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnEnterKey )
	EVT_TEXT_ENTER( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnEnterKey )
	EVT_CHECKBOX( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnVisibleFieldClick )
	EVT_BUTTON( wxID_ADD_FIELD, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnAddButtonClick )
	EVT_BUTTON( wxID_DELETE_FIELD, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnDeleteButtonClick )
END_EVENT_TABLE()
@@ -29,10 +32,10 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
	wxBoxSizer* bOptionsSizer;
	bOptionsSizer = new wxBoxSizer( wxVERTICAL );
	
	m_notebook1 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	m_notebook1->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
	m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	m_notebook->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
	
	m_panel1 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	m_panel1 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	wxBoxSizer* p1mainSizer;
	p1mainSizer = new wxBoxSizer( wxHORIZONTAL );
	
@@ -210,14 +213,14 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
	m_panel1->SetSizer( p1mainSizer );
	m_panel1->Layout();
	p1mainSizer->Fit( m_panel1 );
	m_notebook1->AddPage( m_panel1, _("General Options"), false );
	m_panel2 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	m_notebook->AddPage( m_panel1, _("General Options"), false );
	m_panel2 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	m_panel2->SetToolTip( _("User defined field names for schematic components. ") );
	
	wxBoxSizer* bSizer6;
	bSizer6 = new wxBoxSizer( wxVERTICAL );
	
	templateFieldListCtrl = new wxListCtrl( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
	templateFieldListCtrl = new wxListView( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
	templateFieldListCtrl->SetMinSize( wxSize( 500,-1 ) );
	
	bSizer6->Add( templateFieldListCtrl, 1, wxALIGN_TOP|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 );
@@ -229,14 +232,14 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
	fieldNameLabel->Wrap( -1 );
	fieldSizer->Add( fieldNameLabel, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
	
	fieldNameTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	fieldNameTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
	fieldSizer->Add( fieldNameTextCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
	
	fieldDefaultValueLabel = new wxStaticText( m_panel2, wxID_ANY, _("Default Value"), wxDefaultPosition, wxDefaultSize, 0 );
	fieldDefaultValueLabel->Wrap( -1 );
	fieldSizer->Add( fieldDefaultValueLabel, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
	
	fieldDefaultValueTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	fieldDefaultValueTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
	fieldSizer->Add( fieldDefaultValueTextCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
	
	fieldVisibleCheckbox = new wxCheckBox( m_panel2, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -255,18 +258,18 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
	m_panel2->SetSizer( bSizer6 );
	m_panel2->Layout();
	bSizer6->Fit( m_panel2 );
	m_notebook1->AddPage( m_panel2, _("Template Field Names"), true );
	m_notebook->AddPage( m_panel2, _("Template Field Names"), true );
	
	bOptionsSizer->Add( m_notebook1, 1, wxALL|wxEXPAND, 5 );
	bOptionsSizer->Add( m_notebook, 1, wxALL|wxEXPAND, 5 );
	
	m_sdbSizer1 = new wxStdDialogButtonSizer();
	m_sdbSizer1OK = new wxButton( this, wxID_OK );
	m_sdbSizer1->AddButton( m_sdbSizer1OK );
	m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
	m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
	m_sdbSizer1->Realize();
	m_sdbSizer = new wxStdDialogButtonSizer();
	m_sdbSizerOK = new wxButton( this, wxID_OK );
	m_sdbSizer->AddButton( m_sdbSizerOK );
	m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
	m_sdbSizer->AddButton( m_sdbSizerCancel );
	m_sdbSizer->Realize();
	
	bOptionsSizer->Add( m_sdbSizer1, 0, wxALIGN_BOTTOM|wxALL|wxEXPAND, 6 );
	bOptionsSizer->Add( m_sdbSizer, 0, wxALIGN_BOTTOM|wxALL|wxEXPAND, 6 );
	
	
	mainSizer->Add( bOptionsSizer, 1, wxEXPAND, 12 );
+8 −8

File changed.

Preview size limit exceeded, changes collapsed.

Loading