Merge with -r 22620:23107.
[blender.git] / source / blender / blenkernel / intern / mesh.c
index c92eda6d169f39a60091b5d4c986044896b4d0a2..dcd8a746673b9d3be8ccc4164bb372be1f6bfe97 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);
        }