Page MenuHome
Paste P912

T61353: Avoid cyclic dependencies when picking curve bevobj/taperobj
ActivePublic

Authored by Philipp Oeser (lichtwerk) on Feb 13 2019, 1:23 PM.
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 0d17251454a..2e5ad5620aa 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -392,15 +392,35 @@ static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value)
static bool rna_Curve_otherObject_poll(PointerRNA *ptr, PointerRNA value)
{
Curve *cu = (Curve *)ptr->id.data;
- Object *ob = (Object *)value.data;
+ Object *ob_other = (Object *)value.data;
- if (ob) {
- if (ob->type == OB_CURVE && ob->data != cu) {
- return 1;
+ if (ob_other) {
+ if (ob_other->type == OB_CURVE) {
+ Curve *cu_other = (Curve *)ob_other->data;
+
+ /* to avoid cyclic dependencies
+ * this covers only the very obvious cases of dependency cycles
+ * (much more are possible)
+ * would be cool to have something generic that could query these between datablocks
+ * (based on DEG::deg_graph_detect_cycles(deg_graph)?)
+ * but I guess this would be much more involved... */
+ Curve *cu_other_bevel = cu_other->bevobj ? cu_other->bevobj->data : NULL;
+ Curve *cu_other_taper = cu_other->taperobj ? cu_other->taperobj->data : NULL;
+
+ if (cu_other != cu) {
+ bool ok = true;
+ if (cu_other_bevel && cu_other_bevel == cu) {
+ ok = false;
+ }
+ if (cu_other_taper && cu_other_taper == cu) {
+ ok = false;
+ }
+ return ok;
+ }
}
}
- return 0;
+ return false;
}
static PointerRNA rna_Curve_taperObject_get(PointerRNA *ptr)