Fix crash browsing file/directory properties within popups
Caused by [0] which closed all popups when adding a file selector event.
This was done so pressing "Open..." from the splash closes the splash
however it caused BUTTONS_OT_file_browse & BUTTONS_OT_directory_browse
to crash when changing the path of an RNA property within a popup.
Move the logic to close popups into the splash screen itself.
Since some actions such as opening a URL's should keep the splash open,
resolve by closing the splash when a file selector is opened.
[0]: b49abbec5f
This commit is contained in:
@@ -4298,9 +4298,6 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
|
||||
ScrArea *root_area = nullptr;
|
||||
ARegion *root_region = nullptr;
|
||||
|
||||
/* Close any popups, like when opening a file browser from the splash. */
|
||||
UI_popup_handlers_remove_all(C, &root_win->modalhandlers);
|
||||
|
||||
/* Setting the context window unsets the context area & screen. Avoid doing that, so operators
|
||||
* calling the file browser can operate in the context the browser was opened in. */
|
||||
if (ctx_win != root_win) {
|
||||
|
||||
@@ -170,6 +170,30 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the splash when opening a file-selector.
|
||||
*/
|
||||
static void wm_block_splash_close_on_fileselect(bContext *C, void *arg1, void * /*arg2*/)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
if (!win) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for the event as this will run before the new window/area has been created. */
|
||||
bool has_fileselect = false;
|
||||
LISTBASE_FOREACH (const wmEvent *, event, &win->event_queue) {
|
||||
if (event->type == EVT_FILESELECT) {
|
||||
has_fileselect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_fileselect) {
|
||||
wm_block_close(C, arg1, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void * /*arg*/)
|
||||
{
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
@@ -234,6 +258,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void * /*ar
|
||||
mt = WM_menutype_find("WM_MT_splash", true);
|
||||
}
|
||||
|
||||
UI_block_func_set(block, wm_block_splash_close_on_fileselect, block, nullptr);
|
||||
|
||||
if (mt) {
|
||||
UI_menutype_draw(C, mt, layout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user