Fix for two proxy + undo related crashes:
[blender.git] / source / blender / blenkernel / intern / object.c
index b6f6820ca738f60ac79aaa63affebf3cca9383a2..a25afeafaef5fb3edd115b3ff865439c82d6cecb 100644 (file)
 
 #include "LBM_fluidsim.h"
 
+#ifndef DISABLE_PYTHON
 #include "BPY_extern.h"
+#endif
 
 #include "GPU_material.h"
 
@@ -269,8 +271,10 @@ void free_object(Object *ob)
        free_constraints(&ob->constraints);
        free_constraint_channels(&ob->constraintChannels);
        free_nlastrips(&ob->nlastrips);
-       
+
+#ifndef DISABLE_PYTHON 
        BPY_free_scriptlink(&ob->scriptlink);
+#endif
        
        if(ob->pd){
                if(ob->pd->tex)
@@ -637,9 +641,9 @@ Camera *copy_camera(Camera *cam)
        
        camn= copy_libblock(cam);
        id_us_plus((ID *)camn->ipo);
-
+#ifndef DISABLE_PYTHON
        BPY_copy_scriptlink(&camn->scriptlink);
-       
+#endif 
        return camn;
 }
 
@@ -786,9 +790,9 @@ Lamp *copy_lamp(Lamp *la)
        id_us_plus((ID *)lan->ipo);
 
        if (la->preview) lan->preview = BKE_previewimg_copy(la->preview);
-
+#ifndef DISABLE_PYTHON
        BPY_copy_scriptlink(&la->scriptlink);
-       
+#endif
        return lan;
 }
 
@@ -846,7 +850,9 @@ void make_local_lamp(Lamp *la)
 
 void free_camera(Camera *ca)
 {
+#ifndef DISABLE_PYTHON
        BPY_free_scriptlink(&ca->scriptlink);
+#endif
 }
 
 void free_lamp(Lamp *la)
@@ -855,8 +861,9 @@ void free_lamp(Lamp *la)
        int a;
 
        /* scriptlinks */
-               
+#ifndef DISABLE_PYTHON
        BPY_free_scriptlink(&la->scriptlink);
+#endif
 
        for(a=0; a<MAX_MTEX; a++) {
                mtex= la->mtex[a];
@@ -1156,7 +1163,10 @@ static void copy_object_pose(Object *obn, Object *ob)
                        ListBase targets = {NULL, NULL};
                        bConstraintTarget *ct;
                        
-                       if(con->ipo) {
+                       /* note that we can't change lib linked ipo blocks. for making
+                        * proxies this still works correct however because the object
+                        * is changed to object->proxy_from when evaluating the driver. */
+                       if(con->ipo && !con->ipo->id.lib) {
                                IpoCurve *icu;
                                for(icu= con->ipo->curve.first; icu; icu= icu->next) {
                                        if(icu->driver && icu->driver->ob==ob)
@@ -1202,9 +1212,9 @@ Object *copy_object(Object *ob)
                modifier_copyData(md, nmd);
                BLI_addtail(&obn->modifiers, nmd);
        }
-       
+#ifndef DISABLE_PYTHON 
        BPY_copy_scriptlink(&ob->scriptlink);
-       
+#endif
        obn->prop.first = obn->prop.last = NULL;
        copy_properties(&obn->prop, &ob->prop);
        
@@ -1918,10 +1928,11 @@ void where_is_object_time(Object *ob, float ctime)
                
                constraints_clear_evalob(cob);
        }
-       
+#ifndef DISABLE_PYTHON
        if(ob->scriptlink.totscript && !during_script()) {
                if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_REDRAW);
        }
+#endif
        
        /* set negative scale flag in object */
        Crossf(vec, ob->obmat[0], ob->obmat[1]);
@@ -2288,7 +2299,9 @@ void object_handle_update(Object *ob)
                        }
                        else
                                where_is_object(ob);
+#ifndef DISABLE_PYTHON
                        if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBJECTUPDATE);
+#endif
                }
                
                if(ob->recalc & OB_RECALC_DATA) {
@@ -2364,7 +2377,9 @@ void object_handle_update(Object *ob)
                                                psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
                                }
                        }
+#ifndef DISABLE_PYTHON
                        if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBDATAUPDATE);
+#endif
                }
 
                /* the no-group proxy case, we call update */