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>2015-12-27 13:53:50 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-12-27 14:00:33 +0300
commit3fcf535d2e003ad939fa1f1c7aa4d5da1b38aef7 (patch)
tree0cc5b044cdc1f7b6fa58ad1d0c3c6cafc51a7759 /source/blender/blenkernel/intern/library.c
parentec2ca11cba496294838bfb5fb76f7bfcef2fe8cc (diff)
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all. This change was also needed because we were getting short on ID flags, and future enhancement of 'user_one' ID behavior requires two new ones. id->flag remains for persistent data (fakeuser only, so far!), this also allows us 100% backward & forward compatibility. New id->tag is used for most flags. Though written in .blend files, its content is cleared at read time. Note that .blend file version was bumped, so that we can clear runtimeflags from old .blends, important in case we add new persistent flags in future. Also, behavior of tags (either status ones, or whether they need to be cleared before/after use) has been added as comments to their declaration. Reviewers: sergey, campbellbarton Differential Revision: https://developer.blender.org/D1683
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r--source/blender/blenkernel/intern/library.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index f1e0bc69dbc..14e21a8b014 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -154,9 +154,9 @@ void id_lib_extern(ID *id)
{
if (id) {
BLI_assert(BKE_idcode_is_linkable(GS(id->name)));
- if (id->flag & LIB_INDIRECT) {
- id->flag -= LIB_INDIRECT;
- id->flag |= LIB_EXTERN;
+ if (id->tag & LIB_TAG_INDIRECT) {
+ id->tag -= LIB_TAG_INDIRECT;
+ id->tag |= LIB_TAG_EXTERN;
}
}
}
@@ -223,7 +223,7 @@ void id_fake_user_clear(ID *id)
* if the block can be made local. */
bool id_make_local(ID *id, bool test)
{
- if (id->flag & LIB_INDIRECT)
+ if (id->tag & LIB_TAG_INDIRECT)
return false;
switch (GS(id->name)) {
@@ -549,21 +549,27 @@ ListBase *which_libbase(Main *mainlib, short type)
return NULL;
}
-/* Flag all ids in listbase */
-void BKE_main_id_flag_listbase(ListBase *lb, const short flag, const bool value)
+/**
+ * Clear or set given flags for all ids in listbase (runtime flags only).
+ */
+void BKE_main_id_flag_listbase(ListBase *lb, const int flag, const bool value)
{
ID *id;
if (value) {
- for (id = lb->first; id; id = id->next) id->flag |= flag;
+ for (id = lb->first; id; id = id->next)
+ id->tag |= flag;
}
else {
- const short nflag = ~flag;
- for (id = lb->first; id; id = id->next) id->flag &= nflag;
+ const int nflag = ~flag;
+ for (id = lb->first; id; id = id->next)
+ id->tag &= nflag;
}
}
-/* Flag all ids in listbase */
-void BKE_main_id_flag_all(Main *bmain, const short flag, const bool value)
+/**
+ * Clear or set given flags for all ids in bmain (runtime flags only).
+ */
+void BKE_main_id_flag_all(Main *bmain, const int flag, const bool value)
{
ListBase *lbarray[MAX_LIBARRAY];
int a;
@@ -952,7 +958,7 @@ void *BKE_libblock_copy_ex(Main *bmain, ID *id)
}
id->newid = idn;
- idn->flag |= LIB_NEW;
+ idn->tag |= LIB_TAG_NEW;
BKE_libblock_copy_data(idn, id, false);
@@ -978,7 +984,7 @@ void *BKE_libblock_copy_nolib(ID *id, const bool do_action)
}
id->newid = idn;
- idn->flag |= LIB_NEW;
+ idn->tag |= LIB_TAG_NEW;
idn->us = 1;
BKE_libblock_copy_data(idn, id, do_action);
@@ -1000,8 +1006,8 @@ static bool id_relink_looper(void *UNUSED(user_data), ID **id_pointer, const int
BKE_library_update_ID_link_user(id->newid, id, cd_flag);
*id_pointer = id->newid;
}
- else if (id->flag & LIB_NEW) {
- id->flag &= ~LIB_NEW;
+ else if (id->tag & LIB_TAG_NEW) {
+ id->tag &= ~LIB_TAG_NEW;
BKE_libblock_relink(id);
}
}
@@ -1632,7 +1638,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
id_fake_user_clear(id);
id->lib = NULL;
- id->flag = LIB_LOCAL;
+ id->tag |= LIB_TAG_LOCAL;
new_id(which_libbase(bmain, GS(id->name)), id, NULL);
/* internal bNodeTree blocks inside ID types below
@@ -1666,7 +1672,7 @@ void BKE_main_id_clear_newpoins(Main *bmain)
id = lbarray[a]->first;
while (id) {
id->newid = NULL;
- id->flag &= ~LIB_NEW;
+ id->tag &= ~LIB_TAG_NEW;
id = id->next;
}
}
@@ -1674,7 +1680,8 @@ void BKE_main_id_clear_newpoins(Main *bmain)
static void lib_indirect_test_id(ID *id, Library *lib)
{
-#define LIBTAG(a) if (a && a->id.lib) { a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0
+#define LIBTAG(a) \
+ if (a && a->id.lib) { a->id.tag &= ~LIB_TAG_INDIRECT; a->id.tag |= LIB_TAG_EXTERN; } (void)0
if (id->lib) {
/* datablocks that were indirectly related are now direct links
@@ -1723,12 +1730,12 @@ void BKE_main_id_tag_listbase(ListBase *lb, const bool tag)
ID *id;
if (tag) {
for (id = lb->first; id; id = id->next) {
- id->flag |= LIB_DOIT;
+ id->tag |= LIB_TAG_DOIT;
}
}
else {
for (id = lb->first; id; id = id->next) {
- id->flag &= ~LIB_DOIT;
+ id->tag &= ~LIB_TAG_DOIT;
}
}
}
@@ -1767,27 +1774,27 @@ void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
id->newid = NULL;
idn = id->next; /* id is possibly being inserted again */
- /* The check on the second line (LIB_PRE_EXISTING) is done so its
+ /* The check on the second line (LIB_TAG_PRE_EXISTING) is done so its
* possible to tag data you don't want to be made local, used for
* appending data, so any libdata already linked wont become local
* (very nasty to discover all your links are lost after appending)
* */
- if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) &&
- ((untagged_only == false) || !(id->flag & LIB_PRE_EXISTING)))
+ if (id->tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW) &&
+ ((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING)))
{
if (lib == NULL || id->lib == lib) {
if (id->lib) {
/* for Make Local > All we should be calling id_make_local,
* but doing that breaks append (see #36003 and #36006), we
* we should make it work with all datablocks and id.us==0 */
- id_clear_lib_data(bmain, id); /* sets 'id->flag' */
+ id_clear_lib_data(bmain, id); /* sets 'id->tag' */
/* why sort alphabetically here but not in
* id_clear_lib_data() ? - campbell */
id_sort_by_name(lbarray[a], id);
}
else {
- id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW);
+ id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW);
}
}
}