Skip to content

Singleton of Actions do not work with multiple windows of same application #245

@Czaki

Description

@Czaki

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions