fix [#26995] Crash on bpy.context.object.collision
authorCampbell Barton <ideasman42@gmail.com>
Mon, 18 Apr 2011 01:40:45 +0000 (01:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 18 Apr 2011 01:40:45 +0000 (01:40 +0000)
  use object.collision rather then object.modifiers[...].settings

source/blender/makesrna/intern/rna_object_force.c

index 9aedcab130183a9adc4f4855a24d743e379c521e..13fac68bf9f592cedf69a10e4120f4adabf8edb1 100644 (file)
@@ -322,10 +322,21 @@ static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max)
 
 static char *rna_CollisionSettings_path(PointerRNA *ptr)
 {
+       /* both methods work ok, but return the shorter path */
+#if 0
        Object *ob= (Object*)ptr->id.data;
        ModifierData *md = (ModifierData *)modifiers_findByType(ob, eModifierType_Collision);
-       
-       return BLI_sprintfN("modifiers[\"%s\"].settings", md->name);
+
+       if(md) {
+               return BLI_sprintfN("modifiers[\"%s\"].settings", md->name);
+       }
+       else {
+               return BLI_strdup("");
+       }
+#else
+       /* more reliable */
+       return BLI_strdup("collision");
+#endif
 }
 
 static int rna_SoftBodySettings_use_edges_get(PointerRNA *ptr)