diff options
author | Jacques Lucke <jacques@blender.org> | 2021-06-30 18:27:54 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-06-30 18:46:59 +0300 |
commit | 17a67bf778b87d0d24adfac3bd89bc8d3300c741 (patch) | |
tree | 8eded550236046978c8fa93c498a50b0e6ccad08 /source/blender/editors/space_file | |
parent | ca12d70af0ff4397ed1ce9b5d7d1adadb06e569c (diff) |
UI: custom free function improvements
This changes `UI_but_func_tooltip_set` so that it allows passing a custom free function, which has two benefits:
* The caller can pass `null` to indicate that the value should not be freed.
* Arbitrary c++ data can be passed to the callback (before the struct had to be trivially destructible).
I added `uiFreeArgFunc` and used it in other places where appropriate.
Differential Revision: https://developer.blender.org/D11738
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 46d37d21756..d947d361fdf 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -25,6 +25,8 @@ #include <math.h> #include <string.h> +#include "MEM_guardedalloc.h" + #include "BLI_alloca.h" #include "BLI_blenlib.h" #include "BLI_fileops_types.h" @@ -165,7 +167,7 @@ static void file_draw_icon(const SpaceFile *sfile, const float a2 = dimmed ? 0.3f : 0.0f; but = uiDefIconBut( block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, a1, a2, NULL); - UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path)); + UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path), MEM_freeN); if (drag) { /* TODO duplicated from file_draw_preview(). */ |