From 26723cf2098de050da9450ca088ba54fab5a0569 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Wed, 31 Dec 2025 10:55:40 +0100 Subject: [PATCH 1/2] Sketcher: Reverse #25478 and #26033 --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 45 +++------------------ 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 5f93496c8a..6dd1027834 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3143,6 +3143,11 @@ void ViewProviderSketch::drawEditMarkers(const std::vector& Edit } void ViewProviderSketch::updateData(const App::Property* prop) { + if (std::string(prop->getName()) != "ShapeMaterial") { + // We don't want material to override the colors of sketches. + ViewProvider2DObject::updateData(prop); + } + if (prop == &getSketchObject()->InternalShape) { const auto& shape = getSketchObject()->InternalShape.getValue(); setupCoinGeometry(shape, @@ -3154,43 +3159,6 @@ void ViewProviderSketch::updateData(const App::Property* prop) { if (prop != &getSketchObject()->Constraints) { signalElementsChanged(); } - - // clang-format on - // update placement changes while in edit mode - if (isInEditMode() && prop) { - // check if the changed property is `placement` or `attachmentoffset` - if (strcmp(prop->getName(), "Placement") == 0 - || strcmp(prop->getName(), "AttachmentOffset") == 0) { - -#ifdef FC_DEBUG - Base::Console().warning("updating editing transform!\n"); -#endif - // recalculate the placement matrix - Sketcher::SketchObject* sketchObj = getSketchObject(); - if (sketchObj) { - // use globalPlacement for both attached and unattached sketches - Base::Placement plm = sketchObj->Placement.getValue(); - -#ifdef FC_DEBUG - // log what is actually being set - Base::Console().warning( - "Placement: pos=(%f,%f,%f)\n", - plm.getPosition().x, - plm.getPosition().y, - plm.getPosition().z - ); -#endif - - // update the document's editing transform - getDocument()->setEditingTransform(plm.toMatrix()); - } - } - } - if (std::string(prop->getName()) != "ShapeMaterial") { - // We don't want material to override the colors of sketches. - ViewProvider2DObject::updateData(prop); - } - // clang-format off } void ViewProviderSketch::slotSolverUpdate() @@ -3434,9 +3402,6 @@ bool ViewProviderSketch::setEdit(int ModNum) addNodeToRoot(gridnode); setGridEnabled(true); - // update the documents stored transform - getDocument()->setEditingTransform(plm.toMatrix()); - // create the container for the additional edit data assert(!isInEditMode()); preselection.reset(); From 450789e77bb0ee4a6b01e038db446a42948633c3 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Wed, 31 Dec 2025 10:58:16 +0100 Subject: [PATCH 2/2] 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);