Fix T58756: crash changing shading.type in 3D viewport in inactive screen.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 5 Dec 2018 13:35:55 +0000 (14:35 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 5 Dec 2018 13:40:10 +0000 (14:40 +0100)
source/blender/makesrna/intern/rna_space.c

index 10e4ed70710d2dacfb260b9b185f193cec8d3672..6e01d326767ba2eb20853cf27479e3cea0952dda 100644 (file)
@@ -713,10 +713,10 @@ static int rna_3DViewShading_type_get(PointerRNA *ptr)
 {
        /* Available shading types depend on render engine. */
        Scene *scene = rna_3DViewShading_scene(ptr);
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = (scene) ? RE_engines_find(scene->r.engine) : NULL;
        View3DShading *shading = (View3DShading *)ptr->data;
 
-       if (BKE_scene_uses_blender_eevee(scene)) {
+       if (scene == NULL || BKE_scene_uses_blender_eevee(scene)) {
                return shading->type;
        }
        else if (BKE_scene_uses_blender_workbench(scene)) {
@@ -746,7 +746,7 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
         PropertyRNA *UNUSED(prop), bool *r_free)
 {
        Scene *scene = rna_3DViewShading_scene(ptr);
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = (scene) ? RE_engines_find(scene->r.engine) : NULL;
 
        EnumPropertyItem *item = NULL;
        int totitem = 0;
@@ -754,7 +754,7 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
        RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_WIRE);
        RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_SOLID);
 
-       if (BKE_scene_uses_blender_eevee(scene)) {
+       if (scene == NULL || BKE_scene_uses_blender_eevee(scene)) {
                RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL);
                RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER);
        }