Skip to content
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

Allow menu options to be updatable #12

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Allow menu options to be updatable #12

wants to merge 5 commits into from

Conversation

fireph
Copy link

@fireph fireph commented Apr 23, 2018

This adds a new parameter to the update function such that the menu_options can be updated the same way that the icon/hover text can be updated. I wanted this functionality for an app where an item in the right click menu changes based on state, and this pull request adds this functionality.

I also tried to avoid duplicated code and keep the menu creation code in one central function "_set_menu_options"

self._menu_actions_by_id = set()
self._menu_options = self._add_ids_to_menu_options(list(menu_options))
self._menu_actions_by_id = dict(self._menu_actions_by_id)
self._menu = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about leaking objects here. Shouldn't we call DestroyMenu to free "self._menu" if it is not None? We can also leak submenus in this case.

@fireph
Copy link
Author

fireph commented May 12, 2018

Updated to use DestroyMenu

@fenhl
Copy link

fenhl commented Jun 2, 2018

Any blockers on getting this merged?

DestroyMenu(self._menu)
self._menu = None
if self._hicon != 0:
DestroyIcon(self._hicon)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We mustn't destroy the icon if it is "shared". see comment in _load_icon

@wiggin15
Copy link
Contributor

I am still concerned about resource leaks. When using submenus we call "CreatePopupMenu" more times and these resources have to be deleted. We don't do that today (already bad) and this option could make it worse. We should probably keep a collection of all menu and menu icons we create and release them when updating the options.

@ZacTallberg
Copy link

ZacTallberg commented Aug 27, 2020

@wiggin15 Please please please please can you implement some form of this?? I really want to be able to add new menu options with a dialogue on the fly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants