Fix a crash when cross-reference settings change after a text group is deleted

A text group kept at the bottom of the page, on a master element,
connects to its project's XRefPropertiesChanged with a lambda that has
no context object. The connection belongs to the project, so it
outlives the group: once the group is deleted (paste a coil, undo,
then make any other edit), changing a cross-reference setting in the
project properties calls QTimer::singleShot() on the freed group and
QElectroTech crashes.

Pass the group as the context of that connection and of the
linkedElementChanged one beside it, so Qt removes both when the group
goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-04 14:59:10 +13:00
parent cbacd2bb62
commit e055438f30
@@ -364,9 +364,12 @@ void ElementTextItemGroup::setHoldToBottomPage(bool hold)
// before updating the position of this group
//because the position of this group is related
// to the size of the parent element Xref
//this is the context of both connections, so they go
//when the group is deleted: the project outlives it.
m_linked_changed_timer = connect(
m_parent_element,
&Element::linkedElementChanged,
this,
[this]()
{QTimer::singleShot(200,
this,
@@ -376,6 +379,7 @@ void ElementTextItemGroup::setHoldToBottomPage(bool hold)
m_XrefChanged_timer = connect(
m_parent_element->diagram()->project(),
&QETProject::XRefPropertiesChanged,
this,
[this]()
{QTimer::singleShot(200,
this,