Skip to content

Parent dynamically created actions to actionstoolbar in Settings page

Arjen Hiemstra requested to merge work/ahiemstra/settings_crash into master

While frameworks/kirigami!95 (merged) fixes the issue that things using ActionToolBar crash when actions disappear, it does not fix the underlying issue with actions disappearing. This does.

When using createObject(null), a reference to the created object needs to be kept, otherwise the object gets destroyed. Unfortunately, passing the object to C++ means the JavaScript engine thinks there are no more references to the object and it garbage collects the objects. This then causes a crash since the toolbar wants to access the action. See also https://bugreports.qt.io/browse/QTBUG-25978

To avoid this, parent the created actions to the ActionToolBar so they are only deleted when the toolbar is also deleted. Since the actions do not change, there is no risk that we end up with a lot of dangling actions here.

Merge request reports