[Bf-blender-cvs] [6b6d1e424c5] blender2.7: Cleanup: prevent future issues with ID.tag overflow, clarify somes names.

Brecht Van Lommel noreply at git.blender.org
Tue Feb 26 20:08:47 CET 2019


Commit: 6b6d1e424c5b85d685d4aa8fa65cd22cd92939be
Author: Brecht Van Lommel
Date:   Tue Feb 26 14:14:56 2019 +0100
Branches: blender2.7
https://developer.blender.org/rB6b6d1e424c5b85d685d4aa8fa65cd22cd92939be

Cleanup: prevent future issues with ID.tag overflow, clarify somes names.

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

M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesdna/DNA_ID.h

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index fd148e53fbd..c5a8aaca11c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8187,7 +8187,7 @@ static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, const char *a
 	return bhead;
 }
 
-static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short tag, ID **r_id)
+static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int tag, ID **r_id)
 {
 	/* this routine reads a libblock and its direct data. Use link functions to connect it all
 	 */
@@ -8747,7 +8747,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
 					bhead = blo_nextbhead(fd, bhead);
 				}
 				else {
-					bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_READ | LIB_TAG_EXTERN, NULL);
+					bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_ID_ID | LIB_TAG_EXTERN, NULL);
 				}
 				break;
 				/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
@@ -8954,7 +8954,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
 					id = is_yet_read(fd, ptr, bhead);
 
 				if (id == NULL) {
-					read_libblock(fd, ptr, bhead, LIB_TAG_READ | LIB_TAG_INDIRECT, NULL);
+					read_libblock(fd, ptr, bhead, LIB_TAG_ID_ID | LIB_TAG_INDIRECT, NULL);
 					// commented because this can print way too much
 					// if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name);
 
@@ -8992,7 +8992,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
 		else {
 			id = is_yet_read(fd, mainvar, bhead);
 			if (id == NULL) {
-				read_libblock(fd, mainvar, bhead, LIB_TAG_TESTIND, NULL);
+				read_libblock(fd, mainvar, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, NULL);
 			}
 			else {
 				/* this is actually only needed on UI call? when ID was already read before, and another append
@@ -10095,7 +10095,7 @@ static void give_base_to_groups(
 	}
 }
 
-static ID *create_placeholder(Main *mainvar, const short idcode, const char *idname, const short tag)
+static ID *create_placeholder(Main *mainvar, const short idcode, const char *idname, const int tag)
 {
 	ListBase *lb = which_libbase(mainvar, idcode);
 	ID *ph_id = BKE_libblock_alloc_notest(idcode);
@@ -10131,7 +10131,8 @@ static ID *link_named_part(
 		id = is_yet_read(fd, mainl, bhead);
 		if (id == NULL) {
 			/* not read yet */
-			read_libblock(fd, mainl, bhead, force_indirect ? LIB_TAG_TESTIND : LIB_TAG_TESTEXT, &id);
+			const int tag = force_indirect ? LIB_TAG_INDIRECT : LIB_TAG_EXTERN;
+			read_libblock(fd, mainl, bhead, tag | LIB_TAG_NEED_EXPAND , &id);
 
 			if (id) {
 				/* sort by name in list */
@@ -10208,7 +10209,7 @@ void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh)
 		if (bhead->code == ENDB)
 			break;
 		if (ELEM(bhead->code, ID_OB, ID_GR)) {
-			read_libblock(fd, mainl, bhead, LIB_TAG_TESTIND, &id);
+			read_libblock(fd, mainl, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, &id);
 		}
 
 
@@ -10293,7 +10294,7 @@ static void link_id_part(ReportList *reports, FileData *fd, Main *mainvar, ID *i
 		bhead = find_bhead_from_idname(fd, id->name);
 	}
 
-	id->tag &= ~LIB_TAG_READ;
+	id->tag &= ~LIB_TAG_ID_ID;
 
 	if (!is_valid) {
 		blo_reportf_wrap(
@@ -10495,7 +10496,7 @@ void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
 
 /* ************* READ LIBRARY ************** */
 
-static int mainvar_id_tag_any_check(Main *mainvar, const short tag)
+static int mainvar_id_tag_any_check(Main *mainvar, const int tag)
 {
 	ListBase *lbarray[MAX_LIBARRAY];
 	int a;
@@ -10531,8 +10532,8 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
 		/* test 1: read libdata */
 		mainptr = mainl->next;
 		while (mainptr) {
-			if (mainvar_id_tag_any_check(mainptr, LIB_TAG_READ)) {
-				// printf("found LIB_TAG_READ %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name);
+			if (mainvar_id_tag_any_check(mainptr, LIB_TAG_ID_ID)) {
+				// printf("found LIB_TAG_ID_ID %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name);
 
 				FileData *fd = mainptr->curlib->filedata;
 
@@ -10634,7 +10635,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
 
 					while (id) {
 						ID *idn = id->next;
-						if (id->tag & LIB_TAG_READ) {
+						if (id->tag & LIB_TAG_ID_ID) {
 							BLI_remlink(lbarray[a], id);
 
 							/* When playing with lib renaming and such, you may end with cases where you have
@@ -10682,7 +10683,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
 
 			for (id = lbarray[a]->first; id; id = idn) {
 				idn = id->next;
-				if (id->tag & LIB_TAG_READ) {
+				if (id->tag & LIB_TAG_ID_ID) {
 					BLI_assert(0);
 					BLI_remlink(lbarray[a], id);
 					blo_reportf_wrap(
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 176ea38d89e..20a3aa1d04e 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -319,14 +319,12 @@ enum {
 	 * and is only used (linked) inderectly through other libraries. */
 	LIB_TAG_INDIRECT        = 1 << 1,
 
-	/* RESET_AFTER_USE Three flags used internally in readfile.c,
-	 * to mark IDs needing to be read (only done once). */
-	LIB_TAG_NEED_EXPAND     = 1 << 3,
-	LIB_TAG_TESTEXT         = (LIB_TAG_NEED_EXPAND | LIB_TAG_EXTERN),
-	LIB_TAG_TESTIND         = (LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT),
 	/* RESET_AFTER_USE Flag used internally in readfile.c,
-	 * to mark IDs needing to be linked from a library. */
-	LIB_TAG_READ            = 1 << 4,
+	 * to mark IDs needing to be expanded (only done once). */
+	LIB_TAG_NEED_EXPAND     = 1 << 3,
+	/* RESET_AFTER_USE Flag used internally in readfile.c to mark ID
+	 * placeholders for linked datablocks needing to be read. */
+	LIB_TAG_ID_ID           = 1 << 4,
 	/* RESET_AFTER_USE */
 	LIB_TAG_NEED_LINK       = 1 << 5,



More information about the Bf-blender-cvs mailing list