Fix T63999: Filepath property won't open filebrowser from a popover

To issues caused this:
* The code to launch the filebrowser from a button didn't respect popup
  menus stored in context
* There was actually no popup menu region stored in context for this
  case. Doing so *may* introduce other issues, but the way I did things
  already fixes all issues I've found.
This commit is contained in:
Julian Eisel
2020-01-28 15:08:26 +01:00
parent ba01ea3f8b
commit a5790b2656
3 changed files with 15 additions and 7 deletions

View File

@@ -10599,15 +10599,11 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata))
* number sliding, text editing, or when a menu block is open */
static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSED(userdata))
{
ARegion *ar;
ARegion *menu_region = CTX_wm_menu(C);
ARegion *ar = menu_region ? menu_region : CTX_wm_region(C);
uiBut *but;
int retval = WM_UI_HANDLER_CONTINUE;
ar = CTX_wm_menu(C);
if (!ar) {
ar = CTX_wm_region(C);
}
but = ui_region_find_active_but(ar);
if (but) {
@@ -10670,9 +10666,18 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
ui_blocks_set_tooltips(ar, true);
}
if (but && but->active && but->active->menu) {
/* Set correct context menu-region. The handling button above breaks if we set the region
* first, so only set it for executing the after-funcs. */
CTX_wm_menu_set(C, but->active->menu->region);
}
/* delayed apply callbacks */
ui_apply_but_funcs_after(C);
/* Reset to previous context region. */
CTX_wm_menu_set(C, menu_region);
/* Don't handle double-click events,
* these will be converted into regular clicks which we handle. */
if (retval == WM_UI_HANDLER_CONTINUE) {

View File

@@ -1067,7 +1067,7 @@ void UI_context_active_but_prop_get_filebrowser(const bContext *C,
PropertyRNA **r_prop,
bool *r_is_undo)
{
ARegion *ar = CTX_wm_region(C);
ARegion *ar = CTX_wm_menu(C) ? CTX_wm_menu(C) : CTX_wm_region(C);
uiBlock *block;
uiBut *but, *prevbut = NULL;

View File

@@ -558,6 +558,9 @@ void ED_region_exit(bContext *C, ARegion *ar)
WM_msgbus_clear_by_owner(wm->message_bus, ar);
CTX_wm_region_set(C, prevar);
if (CTX_wm_menu(C) == ar) {
CTX_wm_region_set(C, NULL);
}
}
void ED_area_exit(bContext *C, ScrArea *sa)