UI: add uiItemMenuFN which frees it's argument

This commit is contained in:
2018-10-30 10:46:29 +11:00
parent e3817e5ec1
commit 4205cd269d
2 changed files with 18 additions and 2 deletions

View File

@@ -1941,8 +1941,11 @@ static uiBut *ui_item_menu(
else
but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip);
if (argN) { /* ugly .. */
but->poin = (char *)but;
if (argN) {
/* ugly .. */
if (arg != argN) {
but->poin = (char *)but;
}
but->func_argN = argN;
}
@@ -2078,6 +2081,18 @@ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc
ui_item_menu(layout, name, icon, func, arg, NULL, "", false);
}
/**
* Version of #uiItemMenuF that free's `argN`.
*/
void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN)
{
if (!func)
return;
/* Second 'argN' only ensures it gets freed. */
ui_item_menu(layout, name, icon, func, argN, argN, "", false);
}
typedef struct MenuItemLevel {
int opcontext;
/* don't use pointers to the strings because python can dynamically