Depsgraph: Avoid non-requested allocation of depsgraph
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 3 Nov 2017 15:49:57 +0000 (16:49 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 6 Nov 2017 08:24:23 +0000 (09:24 +0100)
source/blender/blenkernel/intern/scene.c
source/blender/editors/scene/scene_edit.c
source/blender/makesrna/intern/rna_scene_api.c

index 6ae826a20b1045b8b912292cbc06e33dbe462c82..1e034a27e649e9134c8812e5f710168861bb642f 100644 (file)
@@ -2464,8 +2464,5 @@ void BKE_scene_free_depsgraph_hash(Scene *scene)
 Depsgraph *BKE_scene_get_depsgraph(Scene *scene, SceneLayer *scene_layer)
 {
        (void) scene_layer;
-       if (scene->depsgraph_legacy == NULL) {
-               scene->depsgraph_legacy = DEG_graph_new();
-       }
        return scene->depsgraph_legacy;
 }
index 1bbc6b3e91ab04e52674ee240b5133d68b3ed294..3799fed8ac24d65c7df48c3ee3ff5d8c92f3f990 100644 (file)
@@ -125,6 +125,10 @@ void ED_scene_changed_update(Main *bmain, bContext *C, Scene *scene_new, const b
         * per window-workspace combination (using WorkSpaceDataRelation) */
        SceneLayer *layer_new = BLI_findlink(&scene_new->render_layers, scene_new->active_layer);
        Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene_new, layer_new);
+       /* TODO(sergey): This is a temporary solution. */
+       if (depsgraph == NULL) {
+               scene_new->depsgraph_legacy = depsgraph = DEG_graph_new();
+       }
 
        CTX_data_scene_set(C, scene_new);
        BKE_workspace_render_layer_set(CTX_wm_workspace(C), layer_new);
index 0ce8cc205b541aaeb85b1f4324690b9b4a877e9c..76c210ea0ae0512479b4aa0d71087a80520c8679 100644 (file)
@@ -90,6 +90,10 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf
             scene_layer = scene_layer->next)
        {
                Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer);
+               /* TODO(sergey): This is a temporary solution. */
+               if (depsgraph == NULL) {
+                       scene->depsgraph_legacy = depsgraph = DEG_graph_new();
+               }
                BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
        }
 
@@ -136,6 +140,10 @@ static void rna_Scene_update_tagged(Scene *scene, Main *bmain)
             scene_layer = scene_layer->next)
        {
                Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer);
+               /* TODO(sergey): This is a temporary solution. */
+               if (depsgraph == NULL) {
+                       scene->depsgraph_legacy = depsgraph = DEG_graph_new();
+               }
                BKE_scene_graph_update_tagged(bmain->eval_ctx, depsgraph, bmain, scene);
        }