Fix T49229: ID user decrement error when deleting group instance twice.
authorBastien Montagne <montagne29@wanadoo.fr>
Sat, 3 Sep 2016 09:47:17 +0000 (11:47 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Sat, 3 Sep 2016 09:47:17 +0000 (11:47 +0200)
Another great example of inconsistency in usercount handling - dupli_group was considered
as refcounted by readfile.c code (and hence by library_query.c one, which is based on it),
but not by editor/BKE_object code, which never increased group's usercount when creating
an instance of it etc.

To be backported to 2.78.

source/blender/blenkernel/intern/object.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_relations.c

index d736a45516375111672589d74dbfcccd33d025a6..cdd7560e3c43c733fe7525c6c8d9dea2ef4540c6 100644 (file)
@@ -1138,7 +1138,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
        /* increase user numbers */
        id_us_plus((ID *)obn->data);
        id_us_plus((ID *)obn->gpd);
-       id_lib_extern((ID *)obn->dup_group);
+       id_us_plus((ID *)obn->dup_group);
 
        for (a = 0; a < obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
        
index a8b0c28599d3fa944bb55f4b9e62fb5d8f7e7e8b..9f91feee4c62362d931805129591ebb073f332d0 100644 (file)
@@ -998,7 +998,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
                Object *ob = ED_object_add_type(C, OB_EMPTY, group->id.name + 2, loc, rot, false, layer);
                ob->dup_group = group;
                ob->transflag |= OB_DUPLIGROUP;
-               id_lib_extern(&group->id);
+               id_us_plus(&group->id);
 
                /* works without this except if you try render right after, see: 22027 */
                DAG_relations_tag_update(bmain);
index 3dc7d8ebd4b6e664c780505000e03d38e1587b01..111afcdc7a7c943174a78d87adb5209ce9491d39 100644 (file)
@@ -910,7 +910,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
 
                                        base->object->dup_group = ob->dup_group;
                                        if (ob->dup_group)
-                                               id_lib_extern(&ob->dup_group->id);
+                                               id_us_plus(&ob->dup_group->id);
                                }
                                else if (event == 7) {    /* mass */
                                        base->object->mass = ob->mass;
index 067a5ad2b4910c1bdb131ca117ba6967d3f95bda..82c6a14eb7f61e69386026a36727adb23eb4d1c4 100644 (file)
@@ -1609,7 +1609,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
                                        case MAKE_LINKS_DUPLIGROUP:
                                                ob_dst->dup_group = ob_src->dup_group;
                                                if (ob_dst->dup_group) {
-                                                       id_lib_extern(&ob_dst->dup_group->id);
+                                                       id_us_plus(&ob_dst->dup_group->id);
                                                        ob_dst->transflag |= OB_DUPLIGROUP;
                                                }
                                                break;