Fix T82952: Crash changing mesh data block and switching scenes

Regression in 33ac3582bb.
This commit is contained in:
Campbell Barton 2021-01-07 01:35:05 +11:00
parent f0071dfa10
commit 691c021679
Notes: blender-bot 2023-02-14 05:53:42 +01:00
Referenced by issue #83848, Blender crashes when making a collection an asset while in edit mode
Referenced by issue #83216, Potential candidates for corrective releases
Referenced by issue #82952, Blender crashes when changing mesh data block and switching scenes
1 changed files with 6 additions and 1 deletions

View File

@ -1203,7 +1203,12 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
* In this case the custom-data layers used wont always match in `me->runtime.batch_cache`.
* If we want to display regular mesh data, we should have a separate cache for the edit-mesh.
* See T77359. */
const bool is_editmode = (me->edit_mesh != NULL) /* && DRW_object_is_in_edit_mode(ob) */;
const bool is_editmode = (me->edit_mesh != NULL) &&
/* In rare cases we have the edit-mode data but not the generated cache.
* This can happen when switching an objects data to a mesh which
* happens to be in edit-mode in another scene, see: T82952. */
(me->edit_mesh->mesh_eval_final !=
NULL) /* && DRW_object_is_in_edit_mode(ob) */;
/* This could be set for paint mode too, currently it's only used for edit-mode. */
const bool is_mode_active = is_editmode && DRW_object_is_in_edit_mode(ob);