Commit: c66a7822cef2d2fd38ab80e5c8c95de554df73e2 Author: Jacques Lucke Date: Tue May 14 15:38:51 2019 +0200 Branches: master https://developer.blender.org/rBc66a7822cef2d2fd38ab80e5c8c95de554df73e2
Interface: Free argument callback for popups Reviewers: brecht Differential Revision: https://developer.blender.org/D4858 =================================================================== M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_context_menu.c M source/blender/editors/interface/interface_handlers.c M source/blender/editors/interface/interface_intern.h M source/blender/editors/interface/interface_region_menu_pie.c M source/blender/editors/interface/interface_region_menu_popup.c M source/blender/editors/interface/interface_region_popover.c M source/blender/editors/interface/interface_region_popup.c M source/blender/editors/space_node/node_select.c M source/blender/windowmanager/intern/wm_files.c M source/blender/windowmanager/intern/wm_operators.c M source/blender/windowmanager/intern/wm_window.c =================================================================== diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 918883ea0b1..c24b555da38 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -594,9 +594,16 @@ struct uiLayout *UI_pie_menu_layout(struct uiPieMenu *pie); typedef uiBlock *(*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1); typedef void (*uiBlockCancelFunc)(struct bContext *C, void *arg1); -void UI_popup_block_invoke(struct bContext *C, uiBlockCreateFunc func, void *arg); -void UI_popup_block_invoke_ex( - struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext); +void UI_popup_block_invoke(struct bContext *C, + uiBlockCreateFunc func, + void *arg, + void (*arg_free)(void *arg)); +void UI_popup_block_invoke_ex(struct bContext *C, + uiBlockCreateFunc func, + void *arg, + void (*arg_free)(void *arg), + const char *opname, + int opcontext); void UI_popup_block_ex(struct bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 84578afa6f7..0055349d4be 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -266,7 +266,7 @@ static void menu_add_shortcut_cancel(struct bContext *C, void *arg1) static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) { uiBut *but = (uiBut *)arg1; - UI_popup_block_invoke(C, menu_change_shortcut, but); + UI_popup_block_invoke(C, menu_change_shortcut, but, NULL); } static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5c22e37867e..ca5bb945d99 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3785,7 +3785,7 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat } if (func || handlefunc) { - data->menu = ui_popup_block_create(C, data->region, but, func, handlefunc, arg); + data->menu = ui_popup_block_create(C, data->region, but, func, handlefunc, arg, NULL); if (but->block->handle) { data->menu->popup = but->block->handle->popup; } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 4af7fdd779f..33288df15ba 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -539,13 +539,12 @@ struct uiKeyNavLock { typedef uiBlock *(*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); -typedef void (*uiBlockHandleFreeFunc)(struct uiPopupBlockHandle *handle, void *arg1); struct uiPopupBlockCreate { uiBlockCreateFunc create_func; uiBlockHandleCreateFunc handle_create_func; - uiBlockHandleFreeFunc free_func; void *arg; + void (*arg_free)(void *arg); int event_xy[2]; @@ -662,7 +661,8 @@ uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, uiBut *but, uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, - void *arg); + void *arg, + void (*arg_free)(void *arg)); uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but, diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c index dcbbde259f2..330a9d48ff4 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.c +++ b/source/blender/editors/interface/interface_region_menu_pie.c @@ -208,7 +208,7 @@ void UI_pie_menu_end(bContext *C, uiPieMenu *pie) wmWindow *window = CTX_wm_window(C); uiPopupBlockHandle *menu; - menu = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PIE, pie); + menu = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PIE, pie, NULL); menu->popup = true; menu->towardstime = PIL_check_seconds_timer(); diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index b97cbcdfef5..ab3a86ec9e1 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -351,7 +351,7 @@ uiPopupBlockHandle *ui_popup_menu_create( pup->menu_func = menu_func; pup->menu_arg = arg; - handle = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup); + handle = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup, NULL); if (!but) { handle->popup = true; @@ -463,7 +463,7 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup) butregion = pup->butregion; } - menu = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup); + menu = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup, NULL); menu->popup = true; UI_popup_handlers_add(C, &window->modalhandlers, menu, 0); @@ -581,13 +581,17 @@ int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports) /** \name Popup Block API * \{ */ -void UI_popup_block_invoke_ex( - bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext) +void UI_popup_block_invoke_ex(bContext *C, + uiBlockCreateFunc func, + void *arg, + void (*arg_free)(void *arg), + const char *opname, + int opcontext) { wmWindow *window = CTX_wm_window(C); uiPopupBlockHandle *handle; - handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg); + handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg, arg_free); handle->popup = true; handle->can_refresh = true; handle->optype = (opname) ? WM_operatortype_find(opname, 0) : NULL; @@ -598,9 +602,12 @@ void UI_popup_block_invoke_ex( WM_event_add_mousemove(C); } -void UI_popup_block_invoke(bContext *C, uiBlockCreateFunc func, void *arg) +void UI_popup_block_invoke(bContext *C, + uiBlockCreateFunc func, + void *arg, + void (*arg_free)(void *arg)) { - UI_popup_block_invoke_ex(C, func, arg, NULL, WM_OP_INVOKE_DEFAULT); + UI_popup_block_invoke_ex(C, func, arg, arg_free, NULL, WM_OP_INVOKE_DEFAULT); } void UI_popup_block_ex(bContext *C, @@ -613,7 +620,7 @@ void UI_popup_block_ex(bContext *C, wmWindow *window = CTX_wm_window(C); uiPopupBlockHandle *handle; - handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg); + handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg, NULL); handle->popup = true; handle->retvalue = 1; handle->can_refresh = true; @@ -635,7 +642,7 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int wmWindow *window = CTX_wm_window(C); uiPopupBlockHandle *handle; - handle = ui_popup_block_create(C, NULL, NULL, func, NULL, op); + handle = ui_popup_block_create(C, NULL, NULL, func, NULL, op, NULL); handle->popup = 1; handle->retvalue = 1; handle->can_refresh = true; diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c index f149ccd626c..22c62ecd6f7 100644 --- a/source/blender/editors/interface/interface_region_popover.c +++ b/source/blender/editors/interface/interface_region_popover.c @@ -244,7 +244,7 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v return block; } -static void ui_block_free_func_POPOVER(uiPopupBlockHandle *UNUSED(handle), void *arg_pup) +static void ui_block_free_func_POPOVER(void *arg_pup) { uiPopover *pup = arg_pup; if (pup->keymap != NULL) { @@ -282,8 +282,8 @@ uiPopupBlockHandle *ui_popover_panel_create( /* Create popup block. */ uiPopupBlockHandle *handle; - handle = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPOVER, pup); - handle->popup_create_vars.free_func = ui_block_free_func_POPOVER; + handle = ui_popup_block_create( + C, butregion, but, NULL, ui_block_func_POPOVER, pup, ui_block_free_func_POPOVER); handle->can_refresh = true; /* Add handlers. If attached to a button, the button will already @@ -386,8 +386,8 @@ void UI_popover_end(bContext *C, uiPopover *pup, wmKeyMap *keymap) WM_event_set_keymap_handler_post_callback(pup->keymap_handler, popover_keymap_fn, pup); } - handle = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPOVER, pup); - handle->popup_create_vars.free_func = ui_block_free_func_POPOVER; + handle = ui_popup_block_create( + C, NULL, NULL, NULL, ui_block_func_POPOVER, pup, ui_block_free_func_POPOVER); /* Add handlers. */ UI_popup_handlers_add(C, &window->modalhandlers, handle, 0); diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index c4bcd7074d8..bd87439ca9e 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -748,7 +748,8 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs