From 450789e77bb0ee4a6b01e038db446a42948633c3 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Wed, 31 Dec 2025 10:58:16 +0100 Subject: [PATCH] Sketcher: Fix text sometimes reversed when switching from one sketch edit to another. Sometimes when user would switch from editing one sketch to edit to another sketch by double clicking on the new sketch, without living the previous sketch, it would then render the text of constraints backward. This was happening because the unsetEdit of the previous sketch was clearing the selection and adding the old sketch as selected. Then the new setEdit was failing to find the correct editing placement resulting in backward text. --- src/Gui/Document.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 07eae60f8a..73e257b4f0 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -648,8 +648,6 @@ bool Document::trySetEdit(Gui::ViewProvider* p, int ModNum, const char* subname) { auto vp = DocumentP::throwIfCastFails(p); - resetIfEditing(); - auto obj = DocumentP::tryGetObject(vp); std::string _subname = subname ? subname : ""; @@ -660,11 +658,20 @@ bool Document::trySetEdit(Gui::ViewProvider* p, int ModNum, const char* subname) obj = finder.getObject(); vp = finder.getViewProvider(); if (vp->getDocument() != this) { + resetIfEditing(); + return vp->getDocument()->setEdit(vp, ModNum, _subname.c_str()); } } } + // Fix for #13852: When switching edit directly between sketches, resetIfEditing() + // triggers unsetEdit() on the previous sketch which restores its selection. + // This clobbers the selection of the new sketch that ParentFinder relies on. + // Moving resetIfEditing() after ParentFinder ensures we resolve the parent context correctly + // using the current selection before closing the previous edit. + resetIfEditing(); + d->throwIfNotInMap(obj, getDocument()); Application::Instance->setEditDocument(this);