UI: add uiItemMenuFN which frees it's argument
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user