From 727188f5649fd229959de4d94db85df253147976 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sat, 10 Oct 2026 19:33:06 +1300 Subject: [PATCH] Fix master's failing link order test: sort a copy in linkedElements() Element::linkedElements() sorted the element's own list of linked elements by position before returning it, so any caller reordered what is saved. #1441 restores the file's order after linking; #1442 fills the link table through linkedElements(), which sorted it again, so on master a coil's contacts are saved in position order and tst_resaveunchanged::savedLinkOrderKept fails. linkedElements() now returns a sorted copy. Callers still get the list by position; the saved order is left alone. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019Wga9B92BNurDEtxxtCDxf --- sources/qetgraphicsitem/element.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index 02c3ea600..31cddc5eb 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -370,15 +370,14 @@ inline QUuid Element::uuid() const /** @brief Element::linkedElements - @return the list of linked elements, the list is sorted by position + @return the list of linked elements, sorted by position. A sorted copy: + the element's own list keeps the order it is saved in. */ inline QList Element::linkedElements() { - std::sort( - connected_elements.begin(), - connected_elements.end(), - comparPos); - return connected_elements; + QList sorted = connected_elements; + std::sort(sorted.begin(), sorted.end(), comparPos); + return sorted; } #endif