Fix T60815: drag & drop crash when search menu is opened immediately after.
Patch by matc, some further refactoring by me. Differential Revision: https://developer.blender.org/D4250
This commit is contained in:
parent
6500b31728
commit
da1350acdc
Notes:
blender-bot
2023-02-14 03:58:33 +01:00
Referenced by issue #62760, Dragging incorrect object into reference field - Crashes Blender Referenced by issue #60815, Drag and drop causes null pointer exception
|
@ -846,7 +846,7 @@ bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, i
|
|||
/* bfunc gets search item *poin as arg2, or if NULL the old string */
|
||||
void UI_but_func_search_set(
|
||||
uiBut *but, uiButSearchCreateFunc cfunc, uiButSearchFunc sfunc,
|
||||
void *arg1, uiButHandleFunc bfunc, void *active);
|
||||
void *arg, bool free_arg, uiButHandleFunc bfunc, void *active);
|
||||
/* height in pixels, it's using hardcoded values still */
|
||||
int UI_searchbox_size_y(void);
|
||||
int UI_searchbox_size_x(void);
|
||||
|
|
|
@ -2949,7 +2949,7 @@ static void ui_but_free(const bContext *C, uiBut *but)
|
|||
MEM_freeN(but->hold_argN);
|
||||
}
|
||||
|
||||
if (!but->editstr && but->free_search_arg) {
|
||||
if (but->free_search_arg) {
|
||||
MEM_SAFE_FREE(but->search_arg);
|
||||
}
|
||||
|
||||
|
@ -4717,7 +4717,7 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle
|
|||
void UI_but_func_search_set(
|
||||
uiBut *but,
|
||||
uiButSearchCreateFunc search_create_func,
|
||||
uiButSearchFunc search_func, void *arg,
|
||||
uiButSearchFunc search_func, void *arg, bool free_arg,
|
||||
uiButHandleFunc bfunc, void *active)
|
||||
{
|
||||
/* needed since callers don't have access to internal functions
|
||||
|
@ -4726,9 +4726,14 @@ void UI_but_func_search_set(
|
|||
search_create_func = ui_searchbox_create_generic;
|
||||
}
|
||||
|
||||
if (but->free_search_arg) {
|
||||
MEM_SAFE_FREE(but->search_arg);
|
||||
}
|
||||
|
||||
but->search_create_func = search_create_func;
|
||||
but->search_func = search_func;
|
||||
but->search_arg = arg;
|
||||
but->free_search_arg = free_arg;
|
||||
|
||||
if (bfunc) {
|
||||
#ifdef DEBUG
|
||||
|
@ -4817,7 +4822,7 @@ uiBut *uiDefSearchButO_ptr(
|
|||
but = uiDefSearchBut(block, arg, retval, icon, maxlen, x, y, width, height, a1, a2, tip);
|
||||
UI_but_func_search_set(
|
||||
but, ui_searchbox_create_generic, operator_enum_search_cb,
|
||||
but, operator_enum_call_cb, NULL);
|
||||
but, false, operator_enum_call_cb, NULL);
|
||||
|
||||
but->optype = ot;
|
||||
but->opcontext = WM_OP_EXEC_DEFAULT;
|
||||
|
|
|
@ -3138,9 +3138,6 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
|
|||
|
||||
ui_searchbox_free(C, data->searchbox);
|
||||
data->searchbox = NULL;
|
||||
if (but->free_search_arg) {
|
||||
MEM_SAFE_FREE(but->search_arg);
|
||||
}
|
||||
}
|
||||
|
||||
but->editstr = NULL;
|
||||
|
|
|
@ -2115,8 +2115,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
|
|||
|
||||
UI_but_func_search_set(
|
||||
but, ui_searchbox_create_generic, ui_rna_collection_search_cb,
|
||||
coll_search, NULL, NULL);
|
||||
but->free_search_arg = true;
|
||||
coll_search, true, NULL, NULL);
|
||||
}
|
||||
else if (but->type == UI_BTYPE_SEARCH_MENU) {
|
||||
/* In case we fail to find proper searchprop,
|
||||
|
|
|
@ -216,7 +216,7 @@ static uiBlock *template_common_search_menu(
|
|||
}
|
||||
UI_but_func_search_set(
|
||||
but, ui_searchbox_create_generic, search_func,
|
||||
search_arg, handle_func, active_item);
|
||||
search_arg, false, handle_func, active_item);
|
||||
|
||||
|
||||
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
|
||||
|
@ -4348,7 +4348,7 @@ void UI_but_func_operator_search(uiBut *but)
|
|||
{
|
||||
UI_but_func_search_set(
|
||||
but, ui_searchbox_create_operator, operator_search_cb,
|
||||
NULL, operator_call_cb, NULL);
|
||||
NULL, false, operator_call_cb, NULL);
|
||||
}
|
||||
|
||||
void uiTemplateOperatorSearch(uiLayout *layout)
|
||||
|
|
|
@ -1081,7 +1081,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
|
|||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
|
||||
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
|
||||
UI_but_func_search_set(but, NULL, node_find_cb, op->type, node_find_call_cb, NULL);
|
||||
UI_but_func_search_set(but, NULL, node_find_cb, op->type, false, node_find_call_cb, NULL);
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL);
|
||||
|
|
Loading…
Reference in New Issue