In napari we got from users information that menus disappear if user close latest created window.
napari/napari#7588
napari/napari#8024
My investigation shows that it looks to be caused to a singleton nature of Actions in app-model.
|
cache_key = QMenuItemAction._cache_key(app, menu_item) |
|
if cache_key in cls._cache: |
|
res = cls._cache[cache_key] |
|
res.setParent(parent) |
|
return res |
As the latest created window is set to be a parent of actions, then, on close of this window, Qt destroys of actions, so the actions effectively disappear from all windows.
What is the motivation to use singleton of QMenuItemAction, when QModelSubmenu are not singletons?
If it is for update, shouldn't we store them per QMainWindow instance?
In napari we got from users information that menus disappear if user close latest created window.
napari/napari#7588
napari/napari#8024
My investigation shows that it looks to be caused to a singleton nature of Actions in app-model.
app-model/src/app_model/backends/qt/_qaction.py
Lines 178 to 182 in 06c1bc4
As the latest created window is set to be a parent of actions, then, on close of this window, Qt destroys of actions, so the actions effectively disappear from all windows.
What is the motivation to use singleton of
QMenuItemAction, whenQModelSubmenuare not singletons?If it is for update, shouldn't we store them per
QMainWindowinstance?