From 9caeb9dfc7dfe8dcd6507a6b8dce5b98651b40ca Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 14 Dec 2020 23:01:24 +0100 Subject: 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. --- source/blender/editors/space_file/space_file.c | 11 +++++++++-- 1 file 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; } -- cgit v1.2.3