[Bf-blender-cvs] [0b6def7059b] asset-uuid: Fixes for changes in master

Julian Eisel noreply at git.blender.org
Thu Jun 11 11:55:53 CEST 2020


Commit: 0b6def7059b6a64b3cef3ba7d4fa46000aee1761
Author: Julian Eisel
Date:   Thu Jun 11 11:54:45 2020 +0200
Branches: asset-uuid
https://developer.blender.org/rB0b6def7059b6a64b3cef3ba7d4fa46000aee1761

Fixes for changes in master

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

M	source/blender/blenkernel/intern/lib_id_delete.c
M	source/blender/blenkernel/intern/lib_remap.c
D	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/python/intern/bpy_rna_id_collection.c
M	source/blender/python/intern/bpy_rna_id_collection.h
M	source/blender/python/intern/bpy_rna_types_capi.c

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

diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 7c96d0a6401..6fce898fd1e 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -61,6 +61,8 @@ void BKE_libblock_free_data(ID *id, const bool do_id_user)
   }
 
   BKE_animdata_free(id, do_id_user);
+
+  MEM_SAFE_FREE(id->uuid);
 }
 
 void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c
index bc009c80849..3026dd617b5 100644
--- a/source/blender/blenkernel/intern/lib_remap.c
+++ b/source/blender/blenkernel/intern/lib_remap.c
@@ -29,6 +29,7 @@
 #include "BKE_armature.h"
 #include "BKE_collection.h"
 #include "BKE_curve.h"
+#include "BKE_idprop.h"
 #include "BKE_layer.h"
 #include "BKE_lib_id.h"
 #include "BKE_lib_query.h"
@@ -691,433 +692,3 @@ void BKE_libblock_relink_to_newid(ID *id)
 
   BKE_library_foreach_ID_link(NULL, id, id_relink_to_newid_looper, NULL, 0);
 }
-
-void BKE_libblock_free_data(ID *id, const bool do_id_user)
-{
-  if (id->properties) {
-    IDP_FreePropertyContent_ex(id->properties, do_id_user);
-    MEM_freeN(id->properties);
-  }
-
-  if (id->override_library) {
-    BKE_override_library_free(&id->override_library, do_id_user);
-  }
-
-  /* XXX TODO remove animdata handling from each type's freeing func,
-   * and do it here, like for copy! */
-}
-
-void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
-{
-  const short type = GS(id->name);
-  switch (type) {
-    case ID_SCE:
-      BKE_scene_free_ex((Scene *)id, false);
-      break;
-    case ID_LI:
-      BKE_library_free((Library *)id);
-      break;
-    case ID_OB:
-      BKE_object_free((Object *)id);
-      break;
-    case ID_ME:
-      BKE_mesh_free((Mesh *)id);
-      break;
-    case ID_CU:
-      BKE_curve_free((Curve *)id);
-      break;
-    case ID_MB:
-      BKE_mball_free((MetaBall *)id);
-      break;
-    case ID_MA:
-      BKE_material_free((Material *)id);
-      break;
-    case ID_TE:
-      BKE_texture_free((Tex *)id);
-      break;
-    case ID_IM:
-      BKE_image_free((Image *)id);
-      break;
-    case ID_LT:
-      BKE_lattice_free((Lattice *)id);
-      break;
-    case ID_LA:
-      BKE_light_free((Light *)id);
-      break;
-    case ID_CA:
-      BKE_camera_free((Camera *)id);
-      break;
-    case ID_IP: /* Deprecated. */
-      BKE_ipo_free((Ipo *)id);
-      break;
-    case ID_KE:
-      BKE_key_free((Key *)id);
-      break;
-    case ID_WO:
-      BKE_world_free((World *)id);
-      break;
-    case ID_SCR:
-      BKE_screen_free((bScreen *)id);
-      break;
-    case ID_VF:
-      BKE_vfont_free((VFont *)id);
-      break;
-    case ID_TXT:
-      BKE_text_free((Text *)id);
-      break;
-    case ID_SPK:
-      BKE_speaker_free((Speaker *)id);
-      break;
-    case ID_LP:
-      BKE_lightprobe_free((LightProbe *)id);
-      break;
-    case ID_SO:
-      BKE_sound_free((bSound *)id);
-      break;
-    case ID_GR:
-      BKE_collection_free((Collection *)id);
-      break;
-    case ID_AR:
-      BKE_armature_free((bArmature *)id);
-      break;
-    case ID_AC:
-      BKE_action_free((bAction *)id);
-      break;
-    case ID_NT:
-      ntreeFreeTree((bNodeTree *)id);
-      break;
-    case ID_BR:
-      BKE_brush_free((Brush *)id);
-      break;
-    case ID_PA:
-      BKE_particlesettings_free((ParticleSettings *)id);
-      break;
-    case ID_WM:
-      if (free_windowmanager_cb) {
-        free_windowmanager_cb(NULL, (wmWindowManager *)id);
-      }
-      break;
-    case ID_GD:
-      BKE_gpencil_free((bGPdata *)id, true);
-      break;
-    case ID_MC:
-      BKE_movieclip_free((MovieClip *)id);
-      break;
-    case ID_MSK:
-      BKE_mask_free((Mask *)id);
-      break;
-    case ID_LS:
-      BKE_linestyle_free((FreestyleLineStyle *)id);
-      break;
-    case ID_PAL:
-      BKE_palette_free((Palette *)id);
-      break;
-    case ID_PC:
-      BKE_paint_curve_free((PaintCurve *)id);
-      break;
-    case ID_CF:
-      BKE_cachefile_free((CacheFile *)id);
-      break;
-    case ID_WS:
-      BKE_workspace_free((WorkSpace *)id);
-      break;
-  }
-}
-
-/**
- * Complete ID freeing, extended version for corner cases.
- * Can override default (and safe!) freeing process, to gain some speed up.
- *
- * At that point, given id is assumed to not be used by any other data-block already
- * (might not be actually true, in case e.g. several inter-related IDs get freed together...).
- * However, they might still be using (referencing) other IDs, this code takes care of it if
- * #LIB_TAG_NO_USER_REFCOUNT is not defined.
- *
- * \param bmain: #Main database containing the freed #ID,
- * can be NULL in case it's a temp ID outside of any #Main.
- * \param idv: Pointer to ID to be freed.
- * \param flag: Set of \a LIB_ID_FREE_... flags controlling/overriding usual freeing process,
- * 0 to get default safe behavior.
- * \param use_flag_from_idtag: Still use freeing info flags from given #ID datablock,
- * even if some overriding ones are passed in \a flag parameter.
- */
-void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_idtag)
-{
-  ID *id = idv;
-
-  if (use_flag_from_idtag) {
-    if ((id->tag & LIB_TAG_NO_MAIN) != 0) {
-      flag |= LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_UI_USER | LIB_ID_FREE_NO_DEG_TAG;
-    }
-    else {
-      flag &= ~LIB_ID_FREE_NO_MAIN;
-    }
-
-    if ((id->tag & LIB_TAG_NO_USER_REFCOUNT) != 0) {
-      flag |= LIB_ID_FREE_NO_USER_REFCOUNT;
-    }
-    else {
-      flag &= ~LIB_ID_FREE_NO_USER_REFCOUNT;
-    }
-
-    if ((id->tag & LIB_TAG_NOT_ALLOCATED) != 0) {
-      flag |= LIB_ID_FREE_NOT_ALLOCATED;
-    }
-    else {
-      flag &= ~LIB_ID_FREE_NOT_ALLOCATED;
-    }
-  }
-
-  BLI_assert((flag & LIB_ID_FREE_NO_MAIN) != 0 || bmain != NULL);
-  BLI_assert((flag & LIB_ID_FREE_NO_MAIN) != 0 || (flag & LIB_ID_FREE_NOT_ALLOCATED) == 0);
-  BLI_assert((flag & LIB_ID_FREE_NO_MAIN) != 0 || (flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0);
-
-  const short type = GS(id->name);
-
-  if (bmain && (flag & LIB_ID_FREE_NO_DEG_TAG) == 0) {
-    DEG_id_type_tag(bmain, type);
-  }
-
-#ifdef WITH_PYTHON
-#  ifdef WITH_PYTHON_SAFETY
-  BPY_id_release(id);
-#  endif
-  if (id->py_instance) {
-    BPY_DECREF_RNA_INVALIDATE(id->py_instance);
-  }
-#endif
-
-  if ((flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0) {
-    BKE_libblock_relink_ex(bmain, id, NULL, NULL, 0);
-  }
-
-  BKE_libblock_free_datablock(id, flag);
-
-  /* avoid notifying on removed data */
-  if ((flag & LIB_ID_FREE_NO_MAIN) == 0) {
-    BKE_main_lock(bmain);
-  }
-
-  if ((flag & LIB_ID_FREE_NO_UI_USER) == 0) {
-    if (free_notifier_reference_cb) {
-      free_notifier_reference_cb(id);
-    }
-
-    if (remap_editor_id_reference_cb) {
-      remap_editor_id_reference_cb(id, NULL);
-    }
-  }
-
-  if ((flag & LIB_ID_FREE_NO_MAIN) == 0) {
-    ListBase *lb = which_libbase(bmain, type);
-    BLI_remlink(lb, id);
-  }
-
-  BKE_libblock_free_data(id, (flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0);
-
-  if ((flag & LIB_ID_FREE_NO_MAIN) == 0) {
-    BKE_main_unlock(bmain);
-  }
-
-  if ((flag & LIB_ID_FREE_NOT_ALLOCATED) == 0) {
-    MEM_freeN(id);
-  }
-}
-
-/**
- * Complete ID freeing, should be usable in most cases (even for out-of-Main IDs).
- *
- * See #BKE_id_free_ex description for full details.
- *
- * \param bmain: Main database containing the freed ID,
- * can be NULL in case it's a temp ID outside of any Main.
- * \param idv: Pointer to ID to be freed.
- */
-void BKE_id_free(Main *bmain, void *idv)
-{
-  BKE_id_free_ex(bmain, idv, 0, true);
-}
-
-/**
- * Not really a freeing function by itself,
- * it decrements usercount of given id, and only frees it if it reaches 0.
- */
-void BKE_id_free_us(Main *bmain, void *idv) /* test users */
-{
-  ID *id = idv;
-
-  id_us_min(id);
-
-  /* XXX This is a temp (2.77) hack so that we keep same behavior as in 2.76 regarding collections
-   *     when deleting an object. Since only 'user_one' usage of objects is collections,
-   *     and only 'real user' usage of objects is scenes, removing that 'user_one' tag when there
-   *     is no more real (scene) users of an object ensures it gets fully unlinked.
-   *     But only for local objects, not linked ones!
-   *     Otherwise, there is no real way to get rid of an object anymore -
-   *     better handling of this is TODO.
-   */
-  if ((GS(id->name) == ID_OB) && (id->us == 1) && (id->lib == NULL)) {
-    id_us_clear_real(id);
-  }
-
-  if (id->us == 0) {
-    BKE_libblock_unlink(bmain, id, false, false);
-
-    BKE_id_free(bmain, id);
-  }
-}
-
-static void id_delete(Main *bmain, const bool do_tagged_deletion)
-{
-  const int tag = LIB_TAG_DOIT;
-  ListBase *lbarray[MAX_LIBARRAY];
-  Link dummy_link = {0};
-  int base_count, i;
-
-  /* Used by batch tagged deletion, when we call BKE_id_free then, id is no more in Main database,
-   * and has already properly unlinked its other IDs usages.
-   * UI users are always cleared in BKE_libblock_remap_locked() call, so we can always skip it. */
-  const int free_flag = LIB_ID_FREE_NO_UI_USER |
-                        (do_tagged_deletion ? LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_USER_REFCOUNT :
-                                              0);
-  ListBase tagged_deleted_ids = {NULL};
-
-  base_count = set_listbasepointers(bmain, lbarray);
-
-  BKE_main_lock(bmain);
-  if (do_tagged_deletion) {
-    /* Main idea of batch deletion is to remove all IDs to be deleted from Main database.
-     * This means that we won't have to loop over all deleted IDs to remove usages
-     * of other deleted IDs.
-     * This gives tremendous speed-up when deleting a large amount of IDs from a Main
-     * containing thousands of those.
-     * This also means that we have to be very careful here, as we by-pass many 'common'
-     * processing, hence risking to 'corrupt' at least user counts, if not IDs themselves. */
-    bool keep_looping = true;
-    while (keep_looping) {
-      ID *id, *id_next;
-      ID *last_remapped_id = tagged_deleted_ids.last;
-      keep_looping = false;
-
-      /* First t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list