From 48a77b5b09f9dcc8bb62f6f3df5d1c824ffbf10f Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 28 Nov 2023 15:36:43 +0100 Subject: [PATCH] Revert "Aggregation: Fix crash when components are in parent-child relationship" This reverts commit 12428bf1d67bd282c5276383c91d968451b44036 because it triggers a qassert in QObject::setParent when the object is a widget. Change-Id: Ib9b76192f548cd3201fcb78a19ea88ccb5782ba2 Reviewed-by: Eike Ziller --- src/libs/aggregation/aggregate.cpp | 3 --- tests/auto/aggregation/tst_aggregate.cpp | 18 ------------------ 2 files changed, 21 deletions(-) diff --git a/src/libs/aggregation/aggregate.cpp b/src/libs/aggregation/aggregate.cpp index 11d13907f33..7be6437ae2f 100644 --- a/src/libs/aggregation/aggregate.cpp +++ b/src/libs/aggregation/aggregate.cpp @@ -193,9 +193,6 @@ void Aggregate::deleteSelf(QObject *obj) QWriteLocker locker(&lock()); aggregateMap().remove(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; } diff --git a/tests/auto/aggregation/tst_aggregate.cpp b/tests/auto/aggregation/tst_aggregate.cpp index fe865be59e7..eef9a32400c 100644 --- a/tests/auto/aggregation/tst_aggregate.cpp +++ b/tests/auto/aggregation/tst_aggregate.cpp @@ -78,24 +78,6 @@ void tst_Aggregate::deleteAggregation() component1 = new Interface1; delete component1; 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()