From b8a7a66a0ab949d24d7fe6a1ad995ff013e31846 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 5 Jan 2022 16:50:24 -0800 Subject: [PATCH] Keep symbol synced with edit tool Undo/Redo can change the symbol referenced by the symbol drawing tool. This updates the current symbol before important steps to keep the system synced Fixes https://gitlab.com/kicad/code/kicad/issues/10125 --- eeschema/symbol_editor/symbol_editor.cpp | 2 ++ eeschema/tools/symbol_editor_drawing_tools.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 9b895062ce..e69ec5bebb 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -385,6 +385,8 @@ bool SYMBOL_EDIT_FRAME::LoadOneLibrarySymbolAux( LIB_SYMBOL* aEntry, const wxStr RebuildSymbolUnitsList(); SetShowDeMorgan( GetCurSymbol()->HasConversion() ); + ClearUndoRedoList(); + // Display the document information based on the entry selected just in // case the entry is an alias. UpdateMsgPanel(); diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index ba99507805..26a629dbfc 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -339,6 +339,9 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) } else if( evt->IsClick( BUT_LEFT ) && !item ) { + // Update in case the symbol was changed while the tool was running + symbol = m_frame->GetCurSymbol(); + if( !symbol ) continue; @@ -361,6 +364,12 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) else if( item && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) ) { + if( symbol != m_frame->GetCurSymbol() ) + { + symbol = m_frame->GetCurSymbol(); + item->SetParent( symbol ); + } + if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing ) || !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) ) {