diff options
Diffstat (limited to 'source/blender/editors/interface/interface_regions.c')
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 2caf52cf8dc..c621fcf493d 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1701,7 +1701,9 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) ar->do_draw &= ~RGN_DRAW_REFRESH_UI; for (block = ar->uiblocks.first; block; block = block_next) { block_next = block->next; - ui_popup_block_refresh((bContext *)C, block->handle, NULL, NULL); + if (block->handle->can_refresh) { + ui_popup_block_refresh((bContext *)C, block->handle, NULL, NULL); + } } } @@ -1811,6 +1813,8 @@ uiBlock *ui_popup_block_refresh( bContext *C, uiPopupBlockHandle *handle, ARegion *butregion, uiBut *but) { + BLI_assert(handle->can_refresh == true); + const int margin = UI_POPUP_MARGIN; wmWindow *window = CTX_wm_window(C); ARegion *ar = handle->region; @@ -2001,6 +2005,8 @@ uiPopupBlockHandle *ui_popup_block_create( handle->popup_create_vars.arg = arg; handle->popup_create_vars.butregion = but ? butregion : NULL; copy_v2_v2_int(handle->popup_create_vars.event_xy, &window->eventstate->x); + /* caller may free vars used to create this popup, in that case this variable should be disabled. */ + handle->can_refresh = true; /* create area region */ ar = ui_region_temp_add(CTX_wm_screen(C)); @@ -2800,6 +2806,7 @@ uiPopupBlockHandle *ui_popup_menu_create( WM_event_add_mousemove(C); } + handle->can_refresh = false; MEM_freeN(pup); return handle; @@ -2807,14 +2814,17 @@ uiPopupBlockHandle *ui_popup_menu_create( /******************** Popup Menu API with begin and end ***********************/ -/* only return handler, and set optional title */ -uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon) +/** + * Only return handler, and set optional title. + * \param block_name: Assigned to uiBlock.name (useful info for debugging). + */ +uiPopupMenu *UI_popup_menu_begin_ex(bContext *C, const char *title, const char *block_name, int icon) { uiStyle *style = UI_style_get_dpi(); uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu"); uiBut *but; - pup->block = UI_block_begin(C, NULL, __func__, UI_EMBOSS_PULLDOWN); + pup->block = UI_block_begin(C, NULL, block_name, UI_EMBOSS_PULLDOWN); pup->block->flag |= UI_BLOCK_POPUP_MEMORY | UI_BLOCK_IS_FLIP; pup->block->puphash = ui_popup_menu_hash(title); pup->layout = UI_block_layout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, MENU_PADDING, style); @@ -2845,6 +2855,11 @@ uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon) return pup; } +uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon) +{ + return UI_popup_menu_begin_ex(C, title, __func__, icon); +} + /* set the whole structure to work */ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup) { @@ -2860,7 +2875,8 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup) UI_popup_handlers_add(C, &window->modalhandlers, menu, 0); WM_event_add_mousemove(C); - + + menu->can_refresh = false; MEM_freeN(pup); } @@ -2991,6 +3007,7 @@ void UI_pie_menu_end(bContext *C, uiPieMenu *pie) menu, WM_HANDLER_ACCEPT_DBL_CLICK); WM_event_add_mousemove(C); + menu->can_refresh = false; MEM_freeN(pie); } @@ -3203,7 +3220,8 @@ void UI_popup_menu_reports(bContext *C, ReportList *reports) if (pup == NULL) { char title[UI_MAX_DRAW_STR]; BLI_snprintf(title, sizeof(title), "%s: %s", IFACE_("Report"), report->typestr); - pup = UI_popup_menu_begin(C, title, ICON_NONE); + /* popup_menu stuff does just what we need (but pass meaningful block name) */ + pup = UI_popup_menu_begin_ex(C, title, __func__, ICON_NONE); layout = UI_popup_menu_layout(pup); } else { @@ -3332,7 +3350,7 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block) UI_popup_handlers_remove(&win->modalhandlers, block->handle); ui_popup_block_free(C, block->handle); - /* In the case we have nested popups, closing one may need to redraw anorher, see: T48874 */ + /* In the case we have nested popups, closing one may need to redraw another, see: T48874 */ for (ARegion *ar = win->screen->regionbase.first; ar; ar = ar->next) { ED_region_tag_refresh_ui(ar); } |