Fix T47266: Blender crashes from Scripted Expression in Driver

Issue was caused by update RNA callbacks freeing the dependency
graph, which is only needed to tag depsgraph for rebuild.

Solved by using a flag for the depsgraph which indicated that it
is to be rebuilt.
This commit is contained in:
Sergey Sharybin
2016-02-03 14:40:02 +01:00
parent 557074c30a
commit 87cbcd697b
2 changed files with 14 additions and 5 deletions

View File

@@ -130,6 +130,7 @@ typedef struct DagForest {
bool is_acyclic; bool is_acyclic;
int time; /* for flushing/tagging, compare with node->lasttime */ int time; /* for flushing/tagging, compare with node->lasttime */
bool ugly_hack_sorry; /* prevent type check */ bool ugly_hack_sorry; /* prevent type check */
bool need_update;
} DagForest; } DagForest;
// queue operations // queue operations

View File

@@ -935,6 +935,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask)
dag = dag_init(); dag = dag_init();
sce->theDag = dag; sce->theDag = dag;
} }
dag->need_update = false;
/* clear "LIB_TAG_DOIT" flag from all materials, to prevent infinite recursion problems later [#32017] */ /* clear "LIB_TAG_DOIT" flag from all materials, to prevent infinite recursion problems later [#32017] */
BKE_main_id_tag_idcode(bmain, ID_MA, false); BKE_main_id_tag_idcode(bmain, ID_MA, false);
@@ -1440,6 +1441,13 @@ static void scene_sort_groups(Main *bmain, Scene *sce)
} }
} }
static void dag_scene_tag_rebuild(Scene *sce)
{
if (sce->theDag) {
sce->theDag->need_update = true;
}
}
/* free the depency graph */ /* free the depency graph */
static void dag_scene_free(Scene *sce) static void dag_scene_free(Scene *sce)
{ {
@@ -1672,7 +1680,7 @@ void DAG_relations_tag_update(Main *bmain)
if (DEG_depsgraph_use_legacy()) { if (DEG_depsgraph_use_legacy()) {
Scene *sce; Scene *sce;
for (sce = bmain->scene.first; sce; sce = sce->id.next) { for (sce = bmain->scene.first; sce; sce = sce->id.next) {
dag_scene_free(sce); dag_scene_tag_rebuild(sce);
} }
} }
else { else {
@@ -1698,7 +1706,7 @@ void DAG_scene_relations_rebuild(Main *bmain, Scene *sce)
void DAG_scene_relations_update(Main *bmain, Scene *sce) void DAG_scene_relations_update(Main *bmain, Scene *sce)
{ {
if (DEG_depsgraph_use_legacy()) { if (DEG_depsgraph_use_legacy()) {
if (!sce->theDag) if (!sce->theDag || sce->theDag->need_update)
dag_scene_build(bmain, sce); dag_scene_build(bmain, sce);
} }
else { else {
@@ -1975,7 +1983,7 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
return; return;
} }
if (sce->theDag == NULL) { if (sce->theDag == NULL || sce->theDag->need_update) {
printf("DAG zero... not allowed to happen!\n"); printf("DAG zero... not allowed to happen!\n");
DAG_scene_relations_update(bmain, sce); DAG_scene_relations_update(bmain, sce);
} }