diff --git a/src/systemc/core/object.cc b/src/systemc/core/object.cc index 68c52eb065..39403ca34d 100644 --- a/src/systemc/core/object.cc +++ b/src/systemc/core/object.cc @@ -118,7 +118,12 @@ Object::operator = (const Object &) Object::~Object() { - panic_if(!children.empty(), "Parent object still has children.\n"); + // Promote all children to be top level objects. + for (auto child: children) { + addObject(&topLevelObjects, child); + child->_gem5_object->parent = nullptr; + } + children.clear(); if (parent) popObject(&parent->_gem5_object->children, _name); diff --git a/src/systemc/core/object.hh b/src/systemc/core/object.hh index 1317986bce..c87a98b2dc 100644 --- a/src/systemc/core/object.hh +++ b/src/systemc/core/object.hh @@ -99,7 +99,6 @@ class Object Objects children; Events events; sc_core::sc_object *parent; - ObjectsIt parentIt; sc_core::sc_attr_cltn cltn; };