[Bf-blender-cvs] [5f8ad885e1c] blender2.8: Fix some popup menus that don't support it refreshing and crashing.

Brecht Van Lommel noreply at git.blender.org
Mon Apr 30 14:28:13 CEST 2018


Commit: 5f8ad885e1c1a9f54be59201912c7233475e4988
Author: Brecht Van Lommel
Date:   Mon Apr 30 10:27:28 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB5f8ad885e1c1a9f54be59201912c7233475e4988

Fix some popup menus that don't support it refreshing and crashing.

===================================================================

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

===================================================================

diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index 98fab5f42aa..0c43b787a84 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -194,7 +194,6 @@ 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);
 }
 
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index 53f9c47a401..a2491e85aab 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -365,7 +365,6 @@ uiPopupBlockHandle *ui_popup_menu_create(
 		WM_event_add_mousemove(C);
 	}
 
-	handle->can_refresh = false;
 	MEM_freeN(pup);
 
 	return handle;
@@ -456,7 +455,6 @@ 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);
 }
 
@@ -560,6 +558,7 @@ void UI_popup_block_invoke_ex(bContext *C, uiBlockCreateFunc func, void *arg, co
 
 	handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
 	handle->popup = true;
+	handle->can_refresh = true;
 	handle->optype = (opname) ? WM_operatortype_find(opname, 0) : NULL;
 	handle->opcontext = opcontext;
 
@@ -582,6 +581,7 @@ void UI_popup_block_ex(
 	handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
 	handle->popup = true;
 	handle->retvalue = 1;
+	handle->can_refresh = true;
 
 	handle->popup_op = op;
 	handle->popup_arg = arg;
@@ -602,6 +602,7 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int
 	handle = ui_popup_block_create(C, NULL, NULL, func, NULL, op);
 	handle->popup = 1;
 	handle->retvalue = 1;
+	handle->can_refresh = true;
 
 	handle->popup_arg = op;
 	handle->popup_func = operator_cb;
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index f3a953cfc10..dea09393504 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -178,6 +178,7 @@ uiPopupBlockHandle *ui_popover_panel_create(
 	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->can_refresh = true;
 
 	/* Add handlers. If attached to a button, the button will already
 	 * add a modal handler and pass on events. */
@@ -222,7 +223,6 @@ void UI_popover_end(bContext *C, uiPopover *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->can_refresh = false;
 
 	/* Add handlers. */
 	wmWindow *window = CTX_wm_window(C);
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 4f8e9090a4a..cc194b41f1b 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -470,8 +470,6 @@ 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;
@@ -483,6 +481,8 @@ uiBlock *ui_popup_block_refresh(
 	uiBlock *block_old = ar->uiblocks.first;
 	uiBlock *block;
 
+	BLI_assert(!block_old || handle->can_refresh == true);
+
 #ifdef DEBUG
 	wmEvent *event_back = window->eventstate;
 #endif
@@ -673,8 +673,9 @@ uiPopupBlockHandle *ui_popup_block_create(
 	handle->popup_create_vars.but = but;
 	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;
+
+	/* don't allow by default, only if popup type explicitly supports it */
+	handle->can_refresh = false;
 
 	/* create area region */
 	ar = ui_region_temp_add(CTX_wm_screen(C));
@@ -692,7 +693,7 @@ uiPopupBlockHandle *ui_popup_block_create(
 	handle = block->handle;
 
 	/* keep centered on window resizing */
-	if ((block->bounds_type == UI_BLOCK_BOUNDS_POPUP_CENTER) && handle->can_refresh) {
+	if (block->bounds_type == UI_BLOCK_BOUNDS_POPUP_CENTER) {
 		type.listener = ui_block_region_popup_window_listener;
 	}



More information about the Bf-blender-cvs mailing list