Revert "Aggregation: Fix crash when components are in parent-child relationship"

This reverts commit 12428bf1d6 because it triggers a qassert
in QObject::setParent when the object is a widget.

Change-Id: Ib9b76192f548cd3201fcb78a19ea88ccb5782ba2
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2023-11-28 15:36:43 +01:00
parent a35deb1532
commit 48a77b5b09
2 changed files with 0 additions and 21 deletions

View File

@@ -193,9 +193,6 @@ void Aggregate::deleteSelf(QObject *obj)
QWriteLocker locker(&lock()); QWriteLocker locker(&lock());
aggregateMap().remove(obj); aggregateMap().remove(obj);
m_components.removeAll(obj); m_components.removeAll(obj);
// Avoid issues if obj was child of another component of the aggregate.
// The parent is deleted in ~Aggregate and might still have a reference on obj
obj->setParent({});
} }
delete this; delete this;
} }

View File

@@ -78,24 +78,6 @@ void tst_Aggregate::deleteAggregation()
component1 = new Interface1; component1 = new Interface1;
delete component1; delete component1;
QVERIFY(component1 == 0); QVERIFY(component1 == 0);
// do not crash if components are in a child/parent relationship
// parent deleted first
aggregation = new Aggregation::Aggregate;
component1 = new Interface1;
component2 = new Interface2;
component2->setParent(component1);
aggregation->add(component1);
aggregation->add(component2);
delete component1;
// child deleted first
aggregation = new Aggregation::Aggregate;
component1 = new Interface1;
component2 = new Interface2;
component2->setParent(component1);
aggregation->add(component1);
aggregation->add(component2);
delete component2;
} }
void tst_Aggregate::queryAggregation() void tst_Aggregate::queryAggregation()