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.
This commit is contained in:
Bastien Montagne 2016-03-14 14:44:11 +01:00 committed by Sergey Sharybin
parent 8b49fa29ca
commit 80b906cb31
2 changed files with 2 additions and 1 deletions

View File

@ -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;

View File

@ -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))