-
Notifications
You must be signed in to change notification settings - Fork 51
fix: set parent for NetItem to prevent JS release #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Keep QObject parent and logical
m_parentin sync or derive one from the other to avoid inconsistencies.Here you now update
QObjectparent (child->m_item->setParent(m_item)) and logical parent (child->m_parent = m_item) separately, which risks them getting out of sync if any future reparenting only updates one. Please either derivem_parentfromQObject::parent()and drop the manual pointer, or centralize all parent changes in a single helper that updates both together to avoid subtle hierarchy inconsistencies.Suggested implementation:
To fully implement the centralization and keep
QObjectparent and logical parent in sync, you should also:In the corresponding header for
NetItemPrivate(likelynetitemprivate.h), declare a helper method, for example:or, if
m_parentis a more specific type, use that type:In
net-view/operation/private/netitemprivate.cpp, define this helper so that it updates both theQObjectparent and the logicalm_parentin one place, e.g.:Adjust the parameter type and assignment as needed to match the actual type of
m_parent.Search for any other places in the codebase where both
m_item->setParent(...)andm_parent = ...(or equivalent) are called separately, and replace those paired operations with a single call tosetParentItem(...)so that all reparenting goes through this centralized helper.