diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-09-12 10:55:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-09-12 10:59:26 +0300 |
commit | 29af082e4a0f46659f9c54b435ade36f999baa4b (patch) | |
tree | 49c89e5c99bb4f73e4bd69260c39f029496e993d /source/blender/editors/space_file/filesel.c | |
parent | 8c1726918374e1d2d2123e17bae8db5aadde3433 (diff) |
Fix T70255: Setting file browser bookmark from Python crashes
Support setting bookmarks even when the file browser
isn't the active space.
Diffstat (limited to 'source/blender/editors/space_file/filesel.c')
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 306d6cba50e..9fc4e8936f4 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -828,13 +828,23 @@ FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, ARegion *region) return sfile->layout; } -void ED_file_change_dir(bContext *C) +/** + * Support updating the directory even when this isn't the active space + * needed so RNA properties update function isn't context sensitive, see T70255. + */ +void ED_file_change_dir_ex(bContext *C, bScreen *screen, ScrArea *area) { - wmWindowManager *wm = CTX_wm_manager(C); - SpaceFile *sfile = CTX_wm_space_file(C); - + /* May happen when manipulating non-active spaces. */ + if (UNLIKELY(area->spacetype != SPACE_FILE)) { + return; + } + SpaceFile *sfile = area->spacedata.first; if (sfile->params) { - ED_fileselect_clear(wm, CTX_data_scene(C), sfile); + wmWindowManager *wm = CTX_wm_manager(C); + Scene *scene = WM_windows_scene_get_from_screen(wm, screen); + if (LIKELY(scene != NULL)) { + ED_fileselect_clear(wm, scene, sfile); + } /* Clear search string, it is very rare to want to keep that filter while changing dir, * and usually very annoying to keep it actually! */ @@ -853,10 +863,17 @@ void ED_file_change_dir(bContext *C) folderlist_pushdir(sfile->folders_prev, sfile->params->dir); - file_draw_check(C); + file_draw_check_ex(C, area); } } +void ED_file_change_dir(bContext *C) +{ + bScreen *screen = CTX_wm_screen(C); + ScrArea *area = CTX_wm_area(C); + ED_file_change_dir_ex(C, screen, area); +} + int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file) { int match = 0; |