[Bf-blender-cvs] [9caeb9dfc7d] master: Fix Asset Browser crash with undo in "Current File" library with sidebar
Julian Eisel
noreply at git.blender.org
Tue Dec 15 17:04:35 CET 2020
Commit: 9caeb9dfc7dfe8dcd6507a6b8dce5b98651b40ca
Author: Julian Eisel
Date: Mon Dec 14 23:01:24 2020 +0100
Branches: master
https://developer.blender.org/rB9caeb9dfc7dfe8dcd6507a6b8dce5b98651b40ca
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.
===================================================================
M source/blender/editors/space_file/space_file.c
===================================================================
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;
}
More information about the Bf-blender-cvs
mailing list