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.
This commit is contained in:
PaddleStroke
2025-12-31 10:58:16 +01:00
committed by Kacper Donat
parent 26723cf209
commit 450789e77b

View File

@@ -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);