From 7eb13c3d33260ce7220d4410464407adfd3bc24e Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Thu, 6 Apr 2023 11:08:01 +0200
Subject: [PATCH] Symbol editor: clear the edit flags of a pasted pin after
 place it. When pasting a single pin, its edit flags were not cleared, and
 create issues when trying to edit the pasted pin. Fixes #14188
 https://gitlab.com/kicad/code/kicad/issues/14188

---
 eeschema/lib_pin.cpp                       | 4 ++++
 eeschema/tools/symbol_editor_move_tool.cpp | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index 253c79ddda..fd13d19fc3 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -1183,6 +1183,10 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
 
     aList.emplace_back( _( "Pos X" ), aFrame->MessageTextFromValue( pinpos.x, true ) );
     aList.emplace_back( _( "Pos Y" ), aFrame->MessageTextFromValue( pinpos.y, true ) );
+
+    #if 0   // For debug purpose only
+    aList.emplace_back( _( "Flags" ), wxString::Format( "%8.8X", (long)GetFlags() ) );
+    #endif
 }
 
 
diff --git a/eeschema/tools/symbol_editor_move_tool.cpp b/eeschema/tools/symbol_editor_move_tool.cpp
index b3cb0ceaa7..1784e7163a 100644
--- a/eeschema/tools/symbol_editor_move_tool.cpp
+++ b/eeschema/tools/symbol_editor_move_tool.cpp
@@ -317,8 +317,13 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
 
                 try
                 {
-                    if( !pinTool->PlacePin( (LIB_PIN*) selection.Front() ) )
+                    LIB_PIN* curr_pin = (LIB_PIN*) selection.Front();
+                    // PlacePin() will clear the current selection, so we need to reset
+                    // flags of the selected pin here:
+                    if( !pinTool->PlacePin( curr_pin ) )
                         restore_state = true;
+                    else
+                        curr_pin->ClearEditFlags();
                 }
                 catch( const boost::bad_pointer& e )
                 {