Fix T62310: Batch generate data-block previews broken.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 11 Mar 2019 15:49:29 +0000 (16:49 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 11 Mar 2019 16:08:30 +0000 (17:08 +0100)
Some uninitialized colormanagement data was breaking RNA acces for them,
exposed in batch preview management when generating previews for scenes
because we have to backup/restore scene and all its settings
before/after rendering it...

source/blender/blenkernel/BKE_blender_version.h
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/versioning_280.c

index e82efac..7510499 100644 (file)
@@ -24,7 +24,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      47
+#define BLENDER_SUBVERSION      48
 /* Several breakages with 280, e.g. collections vs layers */
 #define BLENDER_MINVERSION      280
 #define BLENDER_MINSUBVERSION   0
index abe0393..580d99e 100644 (file)
@@ -780,6 +780,18 @@ void BKE_scene_init(Scene *sce)
        BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name,
                    sizeof(sce->sequencer_colorspace_settings.name));
 
+       /* Those next two sets (render and baking settings) are not currently in use,
+        * but are exposed to RNA API and hence must have valid data. */
+       BKE_color_managed_display_settings_init(&sce->r.im_format.display_settings);
+       BKE_color_managed_view_settings_init_render(&sce->r.im_format.view_settings,
+                                                   &sce->r.im_format.display_settings,
+                                                   "Filmic");
+
+       BKE_color_managed_display_settings_init(&sce->r.bake.im_format.display_settings);
+       BKE_color_managed_view_settings_init_render(&sce->r.bake.im_format.view_settings,
+                                                   &sce->r.bake.im_format.display_settings,
+                                                   "Filmic");
+
        /* Safe Areas */
        copy_v2_fl2(sce->safe_areas.title, 10.0f / 100.0f, 5.0f / 100.0f);
        copy_v2_fl2(sce->safe_areas.action, 3.5f / 100.0f, 3.5f / 100.0f);
index 3832b67..98277ba 100644 (file)
@@ -2874,6 +2874,26 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
                }
        }
 
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 48)) {
+               for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+                       /* Those are not currently used, but are accessible through RNA API and were not
+                        * properly initialized previously. This is mere copy of BKE_init_scene() code. */
+                       if (scene->r.im_format.view_settings.look[0] == '\0') {
+                               BKE_color_managed_display_settings_init(&scene->r.im_format.display_settings);
+                               BKE_color_managed_view_settings_init_render(&scene->r.im_format.view_settings,
+                                                                           &scene->r.im_format.display_settings,
+                                                                           "Filmic");
+                       }
+
+                       if (scene->r.bake.im_format.view_settings.look[0] == '\0') {
+                               BKE_color_managed_display_settings_init(&scene->r.bake.im_format.display_settings);
+                               BKE_color_managed_view_settings_init_render(&scene->r.bake.im_format.view_settings,
+                                                                           &scene->r.bake.im_format.display_settings,
+                                                                           "Filmic");
+                       }
+               }
+       }
+
        {
                /* Versioning code until next subversion bump goes here. */
        }