Merge pull request #675 from IBSYSLevi/improvement/avoid-needless-dock-churn

Avoid needless dock churn in QETElementEditor::updateInformations()
This commit is contained in:
Laurent Trinques
2026-09-17 13:49:52 +02:00
committed by GitHub
2 changed files with 28 additions and 6 deletions
+10
View File
@@ -156,6 +156,16 @@ bool LineEditor::setParts(QList<CustomElementPart *> parts)
return false;
}
// setPart() no-ops when parts.first() is already m_part (its own
// identity guard), which skips updateForm(). That is fine when this
// editor widget stayed on screen the whole time, but since PR #675
// keeps the same editor instance installed across selection changes
// instead of tearing it down, an already-shown single line can also be
// parts.first() of a later multi-selection -- and without this call
// the geometry spinboxes keep showing whatever was in them before,
// not this selection's actual first line.
updateForm();
return m_style->setParts(parts);
}
+18 -6
View File
@@ -575,9 +575,11 @@ void QETElementEditor::updateInformations()
|| selection_xml_name == "ellipse"
|| selection_xml_name == "arc")
{
clearToolsDock();
//We add the editor widget
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
if (m_tools_dock_stack -> widget(1) != editor) {
clearToolsDock();
}
#if TODO_LIST
#pragma message("@TODO Check if it takes longer than setting the parts again to the editor.")
@@ -610,7 +612,9 @@ void QETElementEditor::updateInformations()
success = editor -> setParts(cep_list);
}
if (success) {
m_tools_dock_stack -> insertWidget(1, editor);
if (m_tools_dock_stack -> widget(1) != editor) {
m_tools_dock_stack -> insertWidget(1, editor);
}
m_tools_dock_stack -> setCurrentIndex(1);
}
else {
@@ -628,8 +632,10 @@ void QETElementEditor::updateInformations()
// multi edit for polygons makes no sense
// TODO: maybe allowing multipart edit when number of points is the same?
//We add the editor widget
clearToolsDock();
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
if (m_tools_dock_stack -> widget(1) != editor) {
clearToolsDock();
}
CustomElementPart* part = editor -> currentPart();
bool equal = part == cep_list.first();
@@ -639,7 +645,9 @@ void QETElementEditor::updateInformations()
success = editor -> setPart(cep_list.first());
}
if (success) {
m_tools_dock_stack -> insertWidget(1, editor);
if (m_tools_dock_stack -> widget(1) != editor) {
m_tools_dock_stack -> insertWidget(1, editor);
}
m_tools_dock_stack -> setCurrentIndex(1);
}
else {
@@ -657,11 +665,15 @@ void QETElementEditor::updateInformations()
//There's several parts selecteds and all can be edited by style editor.
if (style_editable) {
clearToolsDock();
ElementItemEditor *selection_editor = m_editors["style"];
if (m_tools_dock_stack -> widget(1) != selection_editor) {
clearToolsDock();
}
if (selection_editor) {
if (selection_editor -> setParts(cep_list)) {
m_tools_dock_stack -> insertWidget(1, selection_editor);
if (m_tools_dock_stack -> widget(1) != selection_editor) {
m_tools_dock_stack -> insertWidget(1, selection_editor);
}
m_tools_dock_stack -> setCurrentIndex(1);
}
else {