Fix (unreported) invalid handling of IDs usercount in `BKE_mesh_new_from_object_to_bm...
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 27 May 2019 14:46:45 +0000 (16:46 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 27 May 2019 14:48:56 +0000 (16:48 +0200)
Would have broken usercount of mesh used as texco reference e.g.

source/blender/blenkernel/intern/mesh_convert.c

index c7ddb8628f97654820f525536513f640565d218a..fce802727380a97e7251c347d0025ce17a3d6ec8 100644 (file)
@@ -1179,7 +1179,15 @@ static int foreach_libblock_make_original_and_usercount_callback(void *user_data
     return IDWALK_RET_NOP;
   }
   *id_p = DEG_get_original_id(*id_p);
-  id_us_plus(*id_p);
+
+  if (cb_flag & IDWALK_CB_USER) {
+    id_us_plus(*id_p);
+  }
+  else if (cb_flag & IDWALK_CB_USER_ONE) {
+    /* Note: in that context, that one should not be needed (since there should be at least already
+     * one USER_ONE user of that ID), but better be consistent. */
+    id_us_ensure_real(*id_p);
+  }
   return IDWALK_RET_NOP;
 }