Fix tests after adding collection color tagging

Fix a segfault caused by assuming all scenes have a master collection
when applying versioning to old files.
This commit is contained in:
Nathan Craddock 2020-09-16 09:03:37 -06:00
parent 0696eaa3e8
commit 365271a588
2 changed files with 6 additions and 1 deletions

View File

@ -650,6 +650,7 @@ Collection *BKE_collection_master_add()
STRNCPY(master_collection->id.name, "GRMaster Collection");
master_collection->id.flag |= LIB_EMBEDDED_DATA;
master_collection->flag |= COLLECTION_IS_MASTER;
master_collection->color_tag = COLLECTION_COLOR_NONE;
return master_collection;
}

View File

@ -658,7 +658,11 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
collection->color_tag = COLLECTION_COLOR_NONE;
}
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->master_collection->color_tag = COLLECTION_COLOR_NONE;
/* Old files do not have a master collection, but it will be created by
* `BKE_collection_master_add()`. */
if (scene->master_collection) {
scene->master_collection->color_tag = COLLECTION_COLOR_NONE;
}
}
}