From 6322c90c5091695bfb1ec87bd82bd2930b29238b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 22 Jan 2018 13:33:24 +0100 Subject: [PATCH] Symbol editor: Fix incorrect pin edition coupling for non interchangeable multi-units symbols. Fixes: lp:1744680 https://bugs.launchpad.net/kicad/+bug/1744680 --- eeschema/lib_pin.cpp | 10 +++++----- eeschema/lib_pin.h | 6 ++++-- eeschema/libeditframe.cpp | 3 +++ eeschema/libeditframe.h | 4 ++++ eeschema/pinedit.cpp | 4 ++-- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index d9255d0544..8af8d385d6 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -511,7 +511,7 @@ void LIB_PIN::SetVisible( bool visible ) } -void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin ) +void LIB_PIN::EnableEditMode( bool aEnable, bool aEditPinByPin ) { LIB_PINS pinList; @@ -526,11 +526,11 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin ) continue; if( ( pinList[i]->m_position == m_position ) - && ( pinList[i]->m_orientation == m_orientation ) - && !IsNew() - && editPinByPin == false - && enable ) + && ( pinList[i]->m_orientation == m_orientation ) + && !IsNew() && !aEditPinByPin && aEnable ) + { pinList[i]->SetFlags( IS_LINKED | IN_EDIT ); + } else pinList[i]->ClearFlags( IS_LINKED | IN_EDIT ); } diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index cbea6c4f94..d3dfda010a 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -335,9 +335,11 @@ public: * parts or body styles in the component. See SetCommonToAllParts() * and SetCommonToAllBodyStyles() for more information. * - * @param aEnable True marks all common pins for editing mode. False + * @param aEnable = true marks all common pins for editing mode. False * clears the editing mode. - * @param aEditPinByPin Enables the edit pin by pin mode. + * @param aEditPinByPin == true enables the edit pin by pin mode. + * aEditPinByPin == false enables the pin edition coupling between pins at the same location + * if aEnable == false, aEditPinByPin is not used */ void EnableEditMode( bool aEnable, bool aEditPinByPin = false ); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index b3f99a3b51..9da51de76a 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -1075,6 +1075,9 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) // retain in case this wxFrame is re-opened later on the same PROJECT Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, partName ); + + // Ensure pin editind can be coupled for multi unitz + m_editPinsSeparately = aPart && aPart->IsMulti() && aPart->UnitsLocked(); } diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index ce8927fff7..2c5bf7b1ea 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -91,6 +91,10 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME * regardless other pins at the same location. * This requires the user to open each part or body style to make changes * to the other pins at the same location. + * To know if others pins must be coupled when editing a pin, use + * SynchronizePins() instead of m_editPinsSeparately, because SynchronizePins() + * is more reliable (takes in account the fact units are interchangeable, + * there are more than one unit ) */ bool m_editPinsSeparately; diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 7848871502..c425a6d829 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -171,7 +171,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) LastPinCommonUnit = dlg.GetAddToAllParts(); LastPinVisible = dlg.GetVisible(); - pin->EnableEditMode( true, m_editPinsSeparately ); + pin->EnableEditMode( true, SynchronizePins()? false : true ); pin->SetName( dlg.GetPinName() ); pin->SetNameTextSize( GetLastPinNameSize() ); pin->SetNumber( dlg.GetPadName() ); @@ -199,7 +199,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) m_canvas->Refresh(); } - pin->EnableEditMode( false, m_editPinsSeparately ); + pin->EnableEditMode( false ); // Restore pin flags, that can be changed by the dialog editor pin->ClearFlags();