Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2020-01-29 17:00:31 +0300
committerJulian Eisel <eiseljulian@gmail.com>2020-01-29 17:09:06 +0300
commit9cb7ecefceee9f1751c3794d54ad1aa3f477f0aa (patch)
tree6f60ea365447673f335e626150c6929cb552cdfc /source/blender/editors/interface/interface_region_popup.c
parentfee7a3457547606635d098f97f23d47cdda2d653 (diff)
Fix T73487: Crash when opening filebrowser while error is displayed
More concretly, the crash would happen if a filebrowser is opened while an error popup is visisble **in a different window**. Code assumed the popup to be in the active window/screen, but it may actually be displayed in a non-active window. Temporarily override context to ensure this assumption is correct.
Diffstat (limited to 'source/blender/editors/interface/interface_region_popup.c')
-rw-r--r--source/blender/editors/interface/interface_region_popup.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 59d955e0278..867ac652505 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -524,20 +524,44 @@ void ui_popup_block_scrolltest(uiBlock *block)
static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle)
{
- wmWindow *win = CTX_wm_window(C);
+ wmWindow *ctx_win = CTX_wm_window(C);
+ ScrArea *ctx_sa = CTX_wm_area(C);
+ ARegion *ctx_ar = CTX_wm_region(C);
+
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = ctx_win;
bScreen *sc = CTX_wm_screen(C);
+ /* There may actually be a different window active than the one showing the popup, so lookup real
+ * one. */
+ if (BLI_findindex(&sc->regionbase, handle->region) == -1) {
+ for (win = wm->windows.first; win; win = win->next) {
+ sc = WM_window_get_active_screen(win);
+ if (BLI_findindex(&sc->regionbase, handle->region) != -1) {
+ break;
+ }
+ }
+ }
+
+ BLI_assert(win && sc);
+
+ CTX_wm_window_set(C, win);
ui_region_temp_remove(C, sc, handle->region);
+ /* Reset context (area and region were NULL'ed when chaning context window). */
+ CTX_wm_window_set(C, ctx_win);
+ CTX_wm_area_set(C, ctx_sa);
+ CTX_wm_region_set(C, ctx_ar);
+
/* reset to region cursor (only if there's not another menu open) */
if (BLI_listbase_is_empty(&sc->regionbase)) {
- ED_region_cursor_set(win, CTX_wm_area(C), CTX_wm_region(C));
+ ED_region_cursor_set(win, ctx_sa, ctx_ar);
/* in case cursor needs to be changed again */
WM_event_add_mousemove(C);
}
if (handle->scrolltimer) {
- WM_event_remove_timer(CTX_wm_manager(C), win, handle->scrolltimer);
+ WM_event_remove_timer(wm, win, handle->scrolltimer);
}
}