Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-01-14 23:08:22 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-01-15 13:09:16 +0300
commitf55a178db06d6c3bf06ae8c33525d6d1c48c9572 (patch)
treefba4c8a2de5505c0363ebcdbc4b9644b9c975889 /source/blender
parentf52d315c353f74d395f63c85ccd0a1659e929bd5 (diff)
Cleanup: rename BKE_libblock_free_us to BKE_id_free_us.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc2
-rw-r--r--source/blender/blenkernel/BKE_library.h27
-rw-r--r--source/blender/blenkernel/intern/collection.c2
-rw-r--r--source/blender/blenkernel/intern/library_remap.c12
-rw-r--r--source/blender/blenkernel/intern/main.c1
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c4
-rw-r--r--source/blender/blenkernel/intern/object.c2
-rw-r--r--source/blender/collada/DocumentImporter.cpp4
-rw-r--r--source/blender/collada/MeshImporter.cpp2
-rw-r--r--source/blender/editors/mesh/meshtools.c2
10 files changed, 44 insertions, 14 deletions
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index d5431d13d0a..4ea4097764a 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -799,7 +799,7 @@ static void import_endjob(void *user_data)
* the reader and the creation of the Blender object. */
if (ob == NULL) continue;
- BKE_libblock_free_us(data->bmain, ob);
+ BKE_id_free_us(data->bmain, ob);
}
}
else {
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 5285fe430f4..4d96c271785 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -38,6 +38,24 @@ extern "C" {
#include "BLI_compiler_attrs.h"
+/**
+ * Naming: BKE_id_ vs BKE_libblock_
+ *
+ * WARNING: description below is ideal goal, current status of naming does not yet
+ * fully follow it (this is WIP).
+ *
+ * BKE_id_ should be used for rather high-level operations, that involve Main database and
+ * relations with other IDs, and can be considered as 'safe' (as in, in themselves, they leave
+ * affected IDs/Main in a consistent status).
+ *
+ * BKE_libblock_ should be used for lower level operations, that perform some parts of BKE_id_ ones,
+ * but will generally not ensure caller that affected data is in a consistent state
+ * by their own execution alone.
+ *
+ * Consequently, external code should not typically use BKE_libblock_ functions,
+ * except in some specific cases requiring advanced (and potentially dangerous) handling.
+ */
+
struct BlendThumbnail;
struct GHash;
struct ListBase;
@@ -75,15 +93,16 @@ enum {
LIB_ID_CREATE_NO_DEG_TAG = 1 << 8, /* Do not tag new ID for update in depsgraph. */
- /* Specific options to some ID types or usages, may be ignored by unrelated ID copying functions. */
+ /*** Specific options to some ID types or usages. ***/
+ /* May be ignored by unrelated ID copying functions. */
LIB_ID_COPY_NO_PROXY_CLEAR = 1 << 16, /* Object only, needed by make_local code. */
LIB_ID_COPY_NO_PREVIEW = 1 << 17, /* Do not copy preview data, when supported. */
LIB_ID_COPY_CACHES = 1 << 18, /* Copy runtime data caches. */
LIB_ID_COPY_NO_ANIMDATA = 1 << 19, /* Don't copy id->adt, used by ID datablock localization routines. */
LIB_ID_COPY_CD_REFERENCE = 1 << 20, /* Mesh: Reference CD data layers instead of doing real copy. */
- /* XXX Hackish/not-so-nice specific behaviors needed for some corner cases.
- * Ideally we should not have those, but we need them for now... */
+ /*** XXX Hackish/not-so-nice specific behaviors needed for some corner cases. ***/
+ /* Ideally we should not have those, but we need them for now... */
LIB_ID_COPY_ACTIONS = 1 << 24, /* EXCEPTION! Deep-copy actions used by animdata of copied ID. */
LIB_ID_COPY_KEEP_LIB = 1 << 25, /* Keep the library pointer when copying datablock outside of bmain. */
LIB_ID_COPY_SHAPEKEY = 1 << 26, /* EXCEPTION! Deep-copy shapekeys used by copied obdata ID. */
@@ -124,7 +143,7 @@ enum {
void BKE_id_free_ex(struct Main *bmain, void *idv, int flag, const bool use_flag_from_idtag);
void BKE_id_free(struct Main *bmain, void *idv);
-void BKE_libblock_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
+void BKE_id_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
void BKE_libblock_management_main_add(struct Main *bmain, void *idv);
void BKE_libblock_management_main_remove(struct Main *bmain, void *idv);
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index bd7757a29c6..e8e3b9229b6 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -534,7 +534,7 @@ static bool collection_object_remove(Main *bmain, Collection *collection, Object
BKE_collection_object_cache_free(collection);
if (free_us) {
- BKE_libblock_free_us(bmain, ob);
+ BKE_id_free_us(bmain, ob);
}
else {
id_us_min(&ob->id);
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 2ee4e2890a1..cc7967a9bdd 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -811,6 +811,11 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
* 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
+ * \a 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,
@@ -904,6 +909,8 @@ void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_i
/**
* 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.
*/
@@ -912,7 +919,10 @@ void BKE_id_free(Main *bmain, void *idv)
BKE_id_free_ex(bmain, idv, 0, true);
}
-void BKE_libblock_free_us(Main *bmain, void *idv) /* test users */
+/**
+ * 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;
diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c
index e231302f154..61be1579fcf 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -64,6 +64,7 @@ void BKE_main_free(Main *mainvar)
ListBase *lbarray[MAX_LIBARRAY];
int a;
+ /* Since we are remonving whole main, no need to bother 'properly' (and slowly) removing each ID from it. */
const int free_flag = LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_UI_USER | LIB_ID_FREE_NO_USER_REFCOUNT;
MEM_SAFE_FREE(mainvar->blen_thumb);
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 71c21bf3208..659177654d6 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -616,7 +616,7 @@ void BKE_mesh_from_nurbs_displist(
cu->mat = NULL;
cu->totcol = 0;
- /* Do not decrement ob->data usercount here, it's done at end of func with BKE_libblock_free_us() call. */
+ /* Do not decrement ob->data usercount here, it's done at end of func with BKE_id_free_us() call. */
ob->data = me;
ob->type = OB_MESH;
@@ -641,7 +641,7 @@ void BKE_mesh_from_nurbs_displist(
BKE_id_free(bmain, cu);
}
else {
- BKE_libblock_free_us(bmain, cu);
+ BKE_id_free_us(bmain, cu);
}
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index ce4d60f6191..44d5b29d4aa 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3296,7 +3296,7 @@ bool BKE_object_shapekey_free(Main *bmain, Object *ob)
key = *key_p;
*key_p = NULL;
- BKE_libblock_free_us(bmain, key);
+ BKE_id_free_us(bmain, key);
return false;
}
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index e59483fa93c..3ba4129c91c 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -379,7 +379,7 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
Camera *cam = uid_camera_map[cam_uid];
Camera *old_cam = (Camera *)ob->data;
ob->data = cam;
- BKE_libblock_free_us(bmain, old_cam);
+ BKE_id_free_us(bmain, old_cam);
return ob;
}
@@ -396,7 +396,7 @@ Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce
Lamp *la = uid_lamp_map[lamp_uid];
Lamp *old_lamp = (Lamp *)ob->data;
ob->data = la;
- BKE_libblock_free_us(bmain, old_lamp);
+ BKE_id_free_us(bmain, old_lamp);
return ob;
}
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 069215da2b7..3cbb783fcad 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -1105,7 +1105,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
BKE_mesh_calc_normals(new_mesh);
id_us_plus(&old_mesh->id); /* Because BKE_mesh_assign_object would have already decreased it... */
- BKE_libblock_free_us(m_bmain, old_mesh);
+ BKE_id_free_us(m_bmain, old_mesh);
COLLADAFW::MaterialBindingArray& mat_array =
geom->getMaterialBindings();
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 71b63cf3471..adbd6e12048 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -580,7 +580,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* free temp copy of destination shapekeys (if applicable) */
if (nkey) {
/* We can assume nobody is using that ID currently. */
- BKE_id_free_ex(bmain, nkey, LIB_ID_FREE_NO_UI_USER | LIB_ID_FREE_NO_USER_REFCOUNT, false);
+ BKE_id_free_ex(bmain, nkey, LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_UI_USER | LIB_ID_FREE_NO_USER_REFCOUNT, false);
}
/* ensure newly inserted keys are time sorted */