Some operation allowed to set invalid active scene render layer
Forbid this now and do tricks in the versioning code to repair corrupted files. Thanks to Pablo, Caminandes and Koro for discovering this bug!
This commit is contained in:
parent
5811076d0d
commit
f5055d8688
|
@ -288,4 +288,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
|
|||
linestyle->texstep = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Scene *scene;
|
||||
for (scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
int num_layers = BLI_countlist(&scene->r.layers);
|
||||
scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -695,7 +695,12 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
|
|||
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
|
||||
if (scene->nodetree && scene->use_nodes && ntreeHasTree(scene->nodetree, ntree)) {
|
||||
if (node->id == NULL || node->id == (ID *)scene) {
|
||||
int num_layers = BLI_countlist(&scene->r.layers);
|
||||
scene->r.actlay = node->custom1;
|
||||
/* Clamp the value, because it might have come from a different
|
||||
* scene which could have more render layers than new one.
|
||||
*/
|
||||
scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1059,7 +1059,8 @@ static int rna_RenderSettings_active_layer_index_get(PointerRNA *ptr)
|
|||
static void rna_RenderSettings_active_layer_index_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
RenderData *rd = (RenderData *)ptr->data;
|
||||
rd->actlay = value;
|
||||
int num_layers = BLI_countlist(&rd->layers);
|
||||
rd->actlay = min_ff(value, num_layers - 1);
|
||||
}
|
||||
|
||||
static void rna_RenderSettings_active_layer_index_range(PointerRNA *ptr, int *min, int *max,
|
||||
|
|
Loading…
Reference in New Issue