Repository navigation
Release QLayout.takeAt QWidgetItems via shiboken6.delete and avoid QLayout.itemAt in QtFloatLayer - #2276
Merged
Conversation
…ayout.itemAt in QtFloatLayer
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Root Cause
Observed an intermittent crash in
shipped_runright after closing menus and opening a channel:Verified in Python against PySide6/shiboken6:
QLayout.takeAt(0)returns a non-QObjectQWidgetItemwithshiboken6.ownedByPython(item) == False, leaking the C++QWidgetItemon every teardown (side_bar.py:330,menu.py:172,placement.py:141,interactive_dialog.py:155,question.py:142,composer.py:797,plan_panel.py:65).QLayout.itemAt(i)inQtFloatLayercreates C++-ownedQWidgetItemwrappers whoseshiboken6.isValid()staysTrueeven afterQWidget.deleteLater()frees the C++QWidgetItem(valid=200/200), leaving stale entries in shiboken6'sBindingManager. Whenmalloclater reuses that address for a newQWidget(such asQListView.viewport()), shiboken6 hands back the staleQWidgetItemwrapper.Fix
drain_layout_items(layout, *, keep=0)anddelete_layout_widgets(layout, *, keep=0)insrc/toad/qt/metrics.pythat callshiboken6.delete(item)immediately afterlayout.takeAt(0)(0 new cold-start modules; folds 7 duplicatedtakeAt(0)loops — IMPL-12).self.notices.itemAt(i)loops insrc/toad/qt/float_layer.pywithself.findChildren(QtNoticeCard, options=Qt.FindChildOption.FindDirectChildrenOnly)+stale.setParent(None)beforedeleteLater()soQtFloatLayernever wraps aQWidgetItem.Verification
delete_layout_widgets,drain_layout_items,shiboken6.deletestress test (500 items, 0 crashes), andQtFloatLayereviction/order.PRE-SPLASH 253/POST-LOAD 1758(comms=False,pkg=False).qt_inherit_ratchet.py= 0,shadow_check.py= 0,guarded_imports.py= 0,rel_imports= 0.