Tom Rollet has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/51647 )

Change subject: python: remove SimObject children on NULL assignment
......................................................................

python: remove SimObject children on NULL assignment

Before this commit, on assigning NULL to an 'attr' that is a SimObject,
the corresponding children SimObject was not set to NULL.

This makes some SimObject being initialized in the c++ world
even if they are not needed.

This commit set the children to NULL in that case.

Change-Id: I2030d9d1b80c020fa28e50c0eca4f87b756763d6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51647
Reviewed-by: Andreas Sandberg <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/python/m5/SimObject.py
1 file changed, 28 insertions(+), 0 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index d18d879..dec630c 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1443,6 +1443,12 @@
                 e.args = (msg, )
                 raise
             self._values[attr] = value
+
+            # If we assign NULL to an attr that is a SimObject,
+            # remove the corresponding children
+            if attr in self._children and isNullPointer(value):
+                self.clear_child(attr)
+
             # implicitly parent unparented objects assigned as params
             if isSimObjectOrVector(value) and not value.has_parent():
                 self.add_child(attr, value)

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/51647
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I2030d9d1b80c020fa28e50c0eca4f87b756763d6
Gerrit-Change-Number: 51647
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Rollet <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Tom Rollet <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-CC: Nathanael Premillieu <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to