Fix T53638: View layer renaming crashes 2/2

This fixes renaming the view layer via Python.

This bug was introduced originally in 3a95bdfc65d. Although I suspect it was
around for longer, since this commit didn't touch this part of the code.

But basically we need the id of the RNA property to be the one that owns
the data (view layer).
This commit is contained in:
Dalai Felinto 2017-12-27 13:32:30 -02:00
parent b517dc9b2d
commit 110373de6a
3 changed files with 39 additions and 1 deletions

@ -132,7 +132,11 @@ static PointerRNA rna_Context_scene_get(PointerRNA *ptr)
static PointerRNA rna_Context_view_layer_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
return rna_pointer_inherit_refine(ptr, &RNA_ViewLayer, CTX_data_view_layer(C));
Scene *scene = CTX_data_scene(C);
PointerRNA scene_ptr;
RNA_id_pointer_create(&scene->id, &scene_ptr);
return rna_pointer_inherit_refine(&scene_ptr, &RNA_ViewLayer, CTX_data_view_layer(C));
}
static PointerRNA rna_Context_view_render_get(PointerRNA *ptr)

@ -178,3 +178,4 @@ VIEW_LAYER_TEST(scene_copy_e)
VIEW_LAYER_TEST(scene_copy_f)
VIEW_LAYER_TEST(scene_delete)
VIEW_LAYER_TEST(scene_write_read)
VIEW_LAYER_TEST(view_layer_rename)

@ -0,0 +1,33 @@
# ############################################################
# Importing - Same For All Render Layer Tests
# ############################################################
import unittest
import os
import sys
from view_layer_common import *
# ############################################################
# Testing
# ############################################################
class UnitTesting(ViewLayerTesting):
def test_view_layer_rename(self):
"""
See if we can rename view layers.
"""
import bpy
view_layer = bpy.context.view_layer
print("View layer name: " + view_layer.name)
view_layer.name = "New Name"
# ############################################################
# Main - Same For All Render Layer Tests
# ############################################################
if __name__ == '__main__':
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
unittest.main()