From c7624d295755e6dcac1cf407929e03ec6dbb613a Mon Sep 17 00:00:00 2001
From: Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
Date: Thu, 14 Jan 2021 18:47:11 +0000
Subject: [PATCH] pl-editor: Don't update the properties panel while adding a
 shape item (line or rectangle) Fixes a bug that caused a crash when editing
 an item in the properties window before it was fully created

---
 pagelayout_editor/tools/pl_drawing_tools.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp
index 4992e96815..18b6acee21 100644
--- a/pagelayout_editor/tools/pl_drawing_tools.cpp
+++ b/pagelayout_editor/tools/pl_drawing_tools.cpp
@@ -284,10 +284,18 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
 
                 item = dataItem->GetDrawItems()[0];
                 item->SetFlags( IS_NEW );
-                m_selectionTool->AddItemToSel( item );
+
+                // Select the item but don't inform other tools (to prevent the Properties
+                // panel from updating the item before it has been placed)
+                m_selectionTool->AddItemToSel( item, true );
             }
             else    // finish drawing
             {
+                // Now we re-select and inform other tools, so that the Properties panel
+                // is updated.
+                m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
+                m_selectionTool->AddItemToSel( item, false );
+
                 item->ClearEditFlags();
                 item = nullptr;
                 m_toolMgr->RunAction( ACTIONS::activatePointEditor );