Depsgraph: Use explicit bmain pointer passed to layer utilities

it is not necessarily that depsgraph is built from G.bmain.

This will solve issue reported in T51782.
This commit is contained in:
Sergey Sharybin 2017-07-10 16:47:12 +02:00
parent 8692c3a83f
commit 205d750a63
Notes: blender-bot 2023-02-14 08:29:54 +01:00
Referenced by issue #51782, Workspace: Cycles material preview crash
3 changed files with 7 additions and 4 deletions

View File

@ -75,6 +75,7 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
}
/* XXX store scene to access from DAG_get_scene */
m_graph->bmain = bmain;
m_graph->scene = scene;
/* scene objects */

View File

@ -42,6 +42,7 @@
struct ID;
struct GHash;
struct Main;
struct GSet;
struct PointerRNA;
struct PropertyRNA;
@ -164,8 +165,8 @@ struct Depsgraph {
SpinLock lock;
// XXX: additional stuff like eval contexts, mempools for allocating nodes from, etc.
Scene *scene; /* XXX: We really shouldn't do that, but it's required for shader preview */
Main *bmain; /* XXX: For until depsgraph has proper ownership. */
Scene *scene; /* XXX: We really shouldn't do that, but it's required for shader preview. */
};
} // namespace DEG

View File

@ -91,8 +91,9 @@ Scene *DEG_get_scene(Depsgraph *graph)
SceneLayer *DEG_get_scene_layer(Depsgraph *graph)
{
Scene *scene = DEG_get_scene(graph);
if (scene) {
return BKE_scene_layer_context_active(scene);
if (scene != NULL) {
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
return BKE_scene_layer_context_active_ex(deg_graph->bmain, scene);
}
return NULL;
}