Commit: 6b1d77a8052b0706ef2277cb1a5e4f3c67310806
Author: Bastien Montagne
Date:   Mon Mar 14 14:44:11 2016 +0100
Branches: master
https://developer.blender.org/rB6b1d77a8052b0706ef2277cb1a5e4f3c67310806

Fix T47787: When performing operation 'Make single user' -> 'obj&data', object 
could be removed from group.

Similar cause as in T47482, we used to have poor handling of 'user_one' cases 
of ID usage,
leading to inconsistent behavior depending on order of operations e.g.

Here, was object used by a group but not linked in any scene - once linked in 
scene,
their usercount would be 2, leading to 'making single copy', when it's actually 
not needed.
We now have better control here, so let's use it!

Note that other ID 'make single user' code will likely need similar fix 
(Images, etc.).

Safe to be backported to 2.77.

===================================================================

M       source/blender/editors/object/object_relations.c
M       source/blender/makesdna/DNA_ID.h

===================================================================

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 1a3209a..0422ac6 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1749,7 +1749,7 @@ static void single_object_users(Main *bmain, Scene 
*scene, View3D *v3d, const in
                ob = base->object;
 
                if ((base->flag & flag) == flag) {
-                       if (ob->id.lib == NULL && ob->id.us > 1) {
+                       if (ob->id.lib == NULL && ID_REFCOUNT_USERS(ob) > 1) {
                                /* base gets copy of object */
                                obn = BKE_object_copy(ob);
                                base->object = obn;
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 0bf3c35..eff6852 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -260,6 +260,7 @@ typedef struct PreviewImage {
 
 #define ID_FAKE_USERS(id) ((((ID *)id)->flag & LIB_FAKEUSER) ? 1 : 0)
 #define ID_REAL_USERS(id) (((ID *)id)->us - ID_FAKE_USERS(id))
+#define ID_REFCOUNT_USERS(id) (((ID *)id)->us - ((((ID *)id)->tag & 
LIB_TAG_EXTRAUSER_SET) ? 1 : 0) - ID_FAKE_USERS(id))
 
 #define ID_CHECK_UNDO(id) ((GS((id)->name) != ID_SCR) && (GS((id)->name) != 
ID_WM))

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to