diff options
author | Julian Eisel <julian@blender.org> | 2020-12-15 01:01:24 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-12-15 19:03:49 +0300 |
commit | 9caeb9dfc7dfe8dcd6507a6b8dce5b98651b40ca (patch) | |
tree | 882c25fdeb79d32008985b3fe51fc0f6b737129c /source/blender | |
parent | 68e4a902409881ee1f29969c3135700cacfe1a66 (diff) |
Fix Asset Browser crash with undo in "Current File" library with sidebar
When the Asset Browser was showing the "Current File" repository and the
sidebar was open, undoing could crash, because the context API returned freed
data.
Don't let context return anything if a refresh is pending due to data changes
like undo/redo.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 46ae52fd4cf..8be02b952a8 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -790,12 +790,18 @@ static int /*eContextResult*/ file_context(const bContext *C, CTX_data_dir_set(result, file_context_dir); return CTX_RESULT_OK; } - else if (CTX_data_equals(member, "active_file")) { + + /* The following member checks return file-list data, check if that needs refreshing first. */ + if (file_main_region_needs_refresh_before_draw(sfile)) { + return CTX_RESULT_NO_DATA; + } + + if (CTX_data_equals(member, "active_file")) { FileDirEntry *file = filelist_file(sfile->files, params->active_file); CTX_data_pointer_set(result, &screen->id, &RNA_FileSelectEntry, file); return CTX_RESULT_OK; } - else if (CTX_data_equals(member, "active_id")) { + if (CTX_data_equals(member, "active_id")) { const FileDirEntry *file = filelist_file(sfile->files, params->active_file); ID *id = filelist_file_get_id(file); @@ -804,6 +810,7 @@ static int /*eContextResult*/ file_context(const bContext *C, } return CTX_RESULT_OK; } + return CTX_RESULT_MEMBER_NOT_FOUND; } |