From 1b59b471093c9a63336278402d2cbcdc539f647a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 28 Jul 2014 11:24:15 +0200 Subject: [PATCH] Eeschema fixes: fix Bug #1348983 save cmp file crashes cvpcb when eeschema is opened (backannotation crashes). Happens only when some footprint names are not set (blank names). Also fix incorrect backannotation when footprint names contain spaces (put spaces in names is always a bad idea) * Fix minor Bug #1349058 Choose component dialog: Search field loses focus after entering a character and internationalize the dialog. * Fix a subtle bug which prevent eeschema to read the project config file when launched from kicad manager, and when kicad.pro is not found. --- cvpcb/readwrite_dlgs.cpp | 2 +- eeschema/backanno.cpp | 12 +++- eeschema/dialogs/dialog_choose_component.cpp | 1 + .../dialogs/dialog_choose_component_base.cpp | 48 ++++++------- .../dialogs/dialog_choose_component_base.fbp | 67 ++++++++----------- .../dialogs/dialog_choose_component_base.h | 9 +-- eeschema/files-io.cpp | 2 +- pcbnew/pcb_netlist.cpp | 2 +- 8 files changed, 69 insertions(+), 74 deletions(-) diff --git a/cvpcb/readwrite_dlgs.cpp b/cvpcb/readwrite_dlgs.cpp index c48d6dfe89..b0f89692d4 100644 --- a/cvpcb/readwrite_dlgs.cpp +++ b/cvpcb/readwrite_dlgs.cpp @@ -394,7 +394,7 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) STRING_FORMATTER sf; m_netlist.FormatBackAnnotation( &sf ); - +wxMessageBox(sf.GetString()); Kiway().ExpressMail( FRAME_SCH, MAIL_BACKANNOTATE_FOOTPRINTS, sf.GetString() ); } diff --git a/eeschema/backanno.cpp b/eeschema/backanno.cpp index ea7628a86f..de39e8bcb4 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/backanno.cpp @@ -70,13 +70,23 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef #endif CPTREE& back_anno = doc.get_child( "back_annotation" ); + wxString footprint; for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref ) { wxASSERT( ref->first == "ref" ); wxString reference = (UTF8&) ref->second.front().first; - wxString footprint = (UTF8&) ref->second.get_child( "fpid" ).front().first; + + // Ensure the "fpid" node contains a footprint name, + // and get it if exists + if( ref->second.get_child( "fpid" ).size() ) + { + wxString tmp = (UTF8&) ref->second.get_child( "fpid" ).front().first; + footprint = tmp; + } + else + footprint.Empty(); DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); ) diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index 7356137b32..c442a6e0f5 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -77,6 +77,7 @@ void DIALOG_CHOOSE_COMPONENT::OnSearchBoxChange( wxCommandEvent& aEvent ) { m_search_container->UpdateSearchTerm( m_searchBox->GetLineText(0) ); updateSelection(); + m_searchBox->SetFocus(); } diff --git a/eeschema/dialogs/dialog_choose_component_base.cpp b/eeschema/dialogs/dialog_choose_component_base.cpp index 2d84ff23cd..2c69e8edfb 100644 --- a/eeschema/dialogs/dialog_choose_component_base.cpp +++ b/eeschema/dialogs/dialog_choose_component_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 22 2014) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -13,60 +13,54 @@ DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wx { this->SetSizeHints( wxSize( 450,100 ), wxDefaultSize ); - wxBoxSizer* bSizer1; - bSizer1 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSearchSizer; bSearchSizer = new wxBoxSizer( wxHORIZONTAL ); - m_searchLabel = new wxStaticText( this, wxID_ANY, wxT("Search"), wxDefaultPosition, wxDefaultSize, 0 ); + m_searchLabel = new wxStaticText( this, wxID_ANY, _("Filter:"), wxDefaultPosition, wxDefaultSize, 0 ); m_searchLabel->Wrap( -1 ); - bSearchSizer->Add( m_searchLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSearchSizer->Add( m_searchLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); m_searchBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); - bSearchSizer->Add( m_searchBox, 1, wxALL, 5 ); + bSearchSizer->Add( m_searchBox, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer1->Add( bSearchSizer, 0, wxEXPAND, 5 ); + bSizerMain->Add( bSearchSizer, 0, wxEXPAND, 5 ); m_libraryComponentTree = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT ); m_libraryComponentTree->SetMinSize( wxSize( -1,50 ) ); - bSizer1->Add( m_libraryComponentTree, 1, wxALL|wxEXPAND, 5 ); + bSizerMain->Add( m_libraryComponentTree, 1, wxALL|wxEXPAND, 5 ); - wxBoxSizer* bSizer3; - bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerView; + bSizerView = new wxBoxSizer( wxHORIZONTAL ); m_componentView = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER ); m_componentView->SetMinSize( wxSize( 150,150 ) ); - bSizer3->Add( m_componentView, 4, wxEXPAND | wxALL, 5 ); + bSizerView->Add( m_componentView, 4, wxEXPAND | wxALL, 5 ); m_componentDetails = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), wxTE_MULTILINE ); m_componentDetails->SetMinSize( wxSize( -1,100 ) ); - bSizer3->Add( m_componentDetails, 3, wxALL|wxEXPAND, 5 ); + bSizerView->Add( m_componentDetails, 3, wxALL|wxEXPAND, 5 ); - bSizer1->Add( bSizer3, 1, wxEXPAND, 5 ); + bSizerMain->Add( bSizerView, 1, wxEXPAND, 5 ); - wxBoxSizer* bSizer5; - bSizer5 = new wxBoxSizer( wxVERTICAL ); + m_stdButtons = new wxStdDialogButtonSizer(); + m_stdButtonsOK = new wxButton( this, wxID_OK ); + m_stdButtons->AddButton( m_stdButtonsOK ); + m_stdButtonsCancel = new wxButton( this, wxID_CANCEL ); + m_stdButtons->AddButton( m_stdButtonsCancel ); + m_stdButtons->Realize(); - m_button = new wxStdDialogButtonSizer(); - m_buttonOK = new wxButton( this, wxID_OK ); - m_button->AddButton( m_buttonOK ); - m_buttonCancel = new wxButton( this, wxID_CANCEL ); - m_button->AddButton( m_buttonCancel ); - m_button->Realize(); - - bSizer5->Add( m_button, 0, wxALL|wxEXPAND, 5 ); + bSizerMain->Add( m_stdButtons, 0, wxALL|wxEXPAND, 5 ); - bSizer1->Add( bSizer5, 0, wxALIGN_RIGHT, 5 ); - - - this->SetSizer( bSizer1 ); + this->SetSizer( bSizerMain ); this->Layout(); this->Centre( wxBOTH ); diff --git a/eeschema/dialogs/dialog_choose_component_base.fbp b/eeschema/dialogs/dialog_choose_component_base.fbp index 77cf06af9e..10a46ef4b1 100644 --- a/eeschema/dialogs/dialog_choose_component_base.fbp +++ b/eeschema/dialogs/dialog_choose_component_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,7 +14,7 @@ dialog_choose_component_base 1000 none - 0 + 1 dialog_choose_component_base . @@ -90,7 +90,7 @@ - bSizer1 + bSizerMain wxVERTICAL none @@ -104,7 +104,7 @@ none 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT 0 1 @@ -134,7 +134,7 @@ 0 0 wxID_ANY - Search + Filter: 0 @@ -187,7 +187,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL 1 1 @@ -386,7 +386,7 @@ 1 - bSizer3 + bSizerView wxHORIZONTAL none @@ -562,41 +562,30 @@ - + 5 - wxALIGN_RIGHT + wxALL|wxEXPAND 0 - + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 - bSizer5 - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_button - protected - - - - - - - - - - + m_stdButtons + protected + + + + + + + + diff --git a/eeschema/dialogs/dialog_choose_component_base.h b/eeschema/dialogs/dialog_choose_component_base.h index 881b5a5ea3..3897d5ca76 100644 --- a/eeschema/dialogs/dialog_choose_component_base.h +++ b/eeschema/dialogs/dialog_choose_component_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 22 2014) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -10,6 +10,7 @@ #include #include +#include class DIALOG_SHIM; #include "dialog_shim.h" @@ -42,9 +43,9 @@ class DIALOG_CHOOSE_COMPONENT_BASE : public DIALOG_SHIM wxTreeCtrl* m_libraryComponentTree; wxPanel* m_componentView; wxTextCtrl* m_componentDetails; - wxStdDialogButtonSizer* m_button; - wxButton* m_buttonOK; - wxButton* m_buttonCancel; + wxStdDialogButtonSizer* m_stdButtons; + wxButton* m_stdButtonsOK; + wxButton* m_stdButtonsCancel; // Virtual event handlers, overide them in your derived class virtual void OnInterceptSearchBoxKey( wxKeyEvent& event ) { event.Skip(); } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 3832ce3ca6..83950e0a9d 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -358,7 +358,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in msg.Printf( _( "Ready\nWorking dir: '%s'\n" ), GetChars( wxGetCwd() ) ); PrintMsg( msg ); - LoadProjectFile( wxEmptyString, false ); + LoadProjectFile( wxEmptyString, true ); // Clear (if needed) the current active library in libedit because it could be // removed from memory diff --git a/pcbnew/pcb_netlist.cpp b/pcbnew/pcb_netlist.cpp index db56251d8a..90a45a2981 100644 --- a/pcbnew/pcb_netlist.cpp +++ b/pcbnew/pcb_netlist.cpp @@ -95,7 +95,7 @@ void COMPONENT::Format( OUTPUTFORMATTER* aOut, int aNestLevel, int aCtl ) int nl = aNestLevel; aOut->Print( nl, "(ref %s ", aOut->Quotew( m_reference ).c_str() ); - aOut->Print( 0, "(fpid %s)\n", m_fpid.Format().c_str() ); + aOut->Print( 0, "(fpid %s)\n", aOut->Quotew( m_fpid.Format() ).c_str() ); if( ! ( aCtl & CTL_OMIT_EXTRA ) ) {