Commit: 77e9193c23176a8143c1a01434b57594e0b0a8f4
Author: Julian Eisel
Date:   Mon Apr 9 19:24:31 2018 +0200
Branches: master
https://developer.blender.org/rB77e9193c23176a8143c1a01434b57594e0b0a8f4

Fix invalid context when refreshing popups

Patch D2759 by @raa, with minor edits by me.

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

M       source/blender/editors/interface/interface_region_popup.c

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

diff --git a/source/blender/editors/interface/interface_region_popup.c 
b/source/blender/editors/interface/interface_region_popup.c
index 15053f0d8ca..4714efdb4a7 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -303,19 +303,36 @@ static void ui_block_position(wmWindow *window, ARegion 
*butregion, uiBut *but,
 
 static void ui_block_region_draw(const bContext *C, ARegion *ar)
 {
+       ScrArea *ctx_area = CTX_wm_area(C);
+       ARegion *ctx_region = CTX_wm_region(C);
        uiBlock *block;
 
        if (ar->do_draw & RGN_DRAW_REFRESH_UI) {
+               ScrArea *handle_ctx_area;
+               ARegion *handle_ctx_region;
                uiBlock *block_next;
+
                ar->do_draw &= ~RGN_DRAW_REFRESH_UI;
                for (block = ar->uiblocks.first; block; block = block_next) {
                        block_next = block->next;
                        if (block->handle->can_refresh) {
+                               handle_ctx_area = block->handle->ctx_area;
+                               handle_ctx_region = block->handle->ctx_region;
+
+                               if (handle_ctx_area) {
+                                       CTX_wm_area_set((bContext *)C, 
handle_ctx_area);
+                               }
+                               if (handle_ctx_region) {
+                                       CTX_wm_region_set((bContext *)C, 
handle_ctx_region);
+                               }
                                ui_popup_block_refresh((bContext *)C, 
block->handle, NULL, NULL);
                        }
                }
        }
 
+       CTX_wm_area_set((bContext *)C, ctx_area);
+       CTX_wm_region_set((bContext *)C, ctx_region);
+
        for (block = ar->uiblocks.first; block; block = block->next)
                UI_block_draw(C, block);
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to