forked from bartvdbraak/blender
Fix leak using UI_BTYPE_TEXT button w/o a callback
Moving ownership of the string to the button's 'rename_orig' leaked when the button didn't have a uiAfterFunc.
This commit is contained in:
parent
64663b1f73
commit
664e854af7
@ -634,6 +634,15 @@ PointerRNA *ui_handle_afterfunc_add_operator(wmOperatorType *ot, int opcontext,
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a #uiAfterFunc is needed for this button.
|
||||
*/
|
||||
static bool ui_afterfunc_check(const uiBlock *block, const uiBut *but)
|
||||
{
|
||||
return (but->func || but->funcN || but->rename_func || but->optype || but->rnaprop || block->handle_func ||
|
||||
(but->type == UI_BTYPE_BUT_MENU && block->butm_func));
|
||||
}
|
||||
|
||||
static void ui_apply_but_func(bContext *C, uiBut *but)
|
||||
{
|
||||
uiAfterFunc *after;
|
||||
@ -643,9 +652,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
|
||||
* handling is done, i.e. menus are closed, in order to avoid conflicts
|
||||
* with these functions removing the buttons we are working with */
|
||||
|
||||
if (but->func || but->funcN || block->handle_func || but->rename_func ||
|
||||
(but->type == UI_BTYPE_BUT_MENU && block->butm_func) || but->optype || but->rnaprop)
|
||||
{
|
||||
if (ui_afterfunc_check(block, but)) {
|
||||
after = ui_afterfunc_new();
|
||||
|
||||
if (but->func && ELEM(but, but->func_arg1, but->func_arg2)) {
|
||||
@ -899,7 +906,8 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
* having typed something already. */
|
||||
but->rename_orig = BLI_strdup(data->origstr);
|
||||
}
|
||||
else {
|
||||
/* only if there are afterfuncs, otherwise 'renam_orig' isn't freed */
|
||||
else if (ui_afterfunc_check(but->block, but)) {
|
||||
but->rename_orig = data->origstr;
|
||||
data->origstr = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user