Fix crash when accessing `view_layer.depsgraph` through BPY

For the sanity checks to work we don't actually need to check other
scenes. So this function can be simplified so that it does not require
a `Main *`.

Mistake in 5cc08510e0.
This commit is contained in:
Julian Eisel 2020-08-21 11:19:07 +02:00
parent 41d31e100d
commit 7aeaf5da0e
3 changed files with 7 additions and 12 deletions

View File

@ -110,8 +110,7 @@ void BKE_toolsettings_free(struct ToolSettings *toolsettings);
struct Scene *BKE_scene_duplicate(struct Main *bmain, struct Scene *sce, eSceneCopyMethod type);
void BKE_scene_groups_relink(struct Scene *sce);
struct Scene *BKE_scene_find_from_view_layer(const struct Main *bmain,
const struct ViewLayer *layer);
bool BKE_scene_has_view_layer(const struct Scene *scene, const struct ViewLayer *layer);
struct Scene *BKE_scene_find_from_collection(const struct Main *bmain,
const struct Collection *collection);

View File

@ -1129,15 +1129,9 @@ int BKE_scene_base_iter_next(
return iter->phase;
}
Scene *BKE_scene_find_from_view_layer(const Main *bmain, const ViewLayer *layer)
bool BKE_scene_has_view_layer(const Scene *scene, const ViewLayer *layer)
{
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (BLI_findindex(&scene->view_layers, layer) != -1) {
return scene;
}
}
return NULL;
return BLI_findindex(&scene->view_layers, layer) != -1;
}
Scene *BKE_scene_find_from_collection(const Main *bmain, const Collection *collection)
@ -2255,9 +2249,11 @@ static Depsgraph **scene_get_depsgraph_p(Main *bmain,
const bool allocate_ghash_entry,
const bool allocate_depsgraph)
{
/* bmain may be NULL here! */
BLI_assert(scene != NULL);
BLI_assert(view_layer != NULL);
BLI_assert(BKE_scene_find_from_view_layer(bmain, view_layer) == scene);
BLI_assert(BKE_scene_has_view_layer(scene, view_layer));
/* Make sure hash itself exists. */
if (allocate_ghash_entry) {
BKE_scene_ensure_depsgraph_hash(scene);

View File

@ -929,7 +929,7 @@ static const char *rna_Scene_statistics_string_get(Scene *scene,
ReportList *reports,
ViewLayer *view_layer)
{
if (BKE_scene_find_from_view_layer(bmain, view_layer) != scene) {
if (!BKE_scene_has_view_layer(scene, view_layer)) {
BKE_reportf(reports,
RPT_ERROR,
"View Layer '%s' not found in scene '%s'",