Merge with 2.5 -r 21756:22173.
[blender.git] / source / blender / blenkernel / intern / mesh.c
index c7454d3b832fed1311d2aff21ddce7d74398be69..695bb6e3fa376fc0f1647e0b2e982d6ef14b0e1a 100644 (file)
@@ -542,7 +542,8 @@ void set_mesh(Object *ob, Mesh *me)
        
        if(ob->type==OB_MESH) {
                old= ob->data;
-               old->id.us--;
+               if (old) /* to make set_mesh work on objects created with add_only_object, i.e. having ob->data == NULL */
+                       old->id.us--;
                ob->data= me;
                id_us_plus((ID *)me);
        }