[Bf-blender-cvs] [b895308] missing-libs: Cleanup.

Bastien Montagne noreply at git.blender.org
Wed Oct 14 16:23:21 CEST 2015


Commit: b89530845aa578c33365fe8b2eba3ac2be36ea8b
Author: Bastien Montagne
Date:   Wed Oct 14 16:22:57 2015 +0200
Branches: missing-libs
https://developer.blender.org/rBb89530845aa578c33365fe8b2eba3ac2be36ea8b

Cleanup.

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

M	source/blender/blenkernel/BKE_font.h
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index ad34e77..76879e2 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -78,7 +78,7 @@ bool BKE_vfont_is_builtin(struct VFont *vfont);
 void BKE_vfont_builtin_register(void *mem, int size);
 
 void BKE_vfont_free_data(struct VFont *vfont);
-void BKE_vfont_free(struct VFont *sc, const bool do_id_user);
+void BKE_vfont_free(struct VFont *sc);
 void BKE_vfont_init(struct VFont *vfont);
 struct VFont *BKE_vfont_builtin_get(void);
 struct VFont *BKE_vfont_load(struct Main *bmain, const char *filepath);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 5a8b6ff..d29eaee 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -839,12 +839,11 @@ void BKE_libblock_init_empty(ID *id)
 			break;
 		case ID_IP:
 			/* Should not be needed - animation from lib pre-2.5 is broken anyway. */
-			/* TDOD: check this does not break completely at least. */
+			BLI_assert(0);
 			break;
 		case ID_KE:
-			/* XXX Shapekeys are a complex topic too - they depend on their 'user' data type...
-			 *     I think it should never reach here anyway (afaik you cannot link skeys).
-			 *     Adding an assert to be sure. */
+			/* Shapekeys are a complex topic too - they depend on their 'user' data type...
+			 * They are not linkable, though, so it should never reach here anyway. */
 			BLI_assert(0);
 			break;
 		case ID_WO:
@@ -863,7 +862,7 @@ void BKE_libblock_init_empty(ID *id)
 			BLI_assert(0);
 			break;
 		case ID_SO:
-			/* XXX Another fuzzy case, thing NULLified content is OK here... */
+			/* Another fuzzy case, think NULLified content is OK here... */
 			break;
 		case ID_GR:
 			/* Nothing to do. */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 015a6a7..4c8bdbd 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -619,21 +619,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
 	m = BKE_main_new();
 	BLI_addtail(mainlist, m);
 	
-	/* Adapted from BKE_libblock_alloc(), with no lock of main, it's most likely already locked by caller code. */
-	lib = BKE_libblock_alloc_notest(ID_LI);
-	{
-		/* Add library datablock itself to 'main' Main, since libraries are **never** linked data.
-		 * Fixes bug where you could end with all ID_LI datablocks having the same name... */
-		ListBase *libraries = &((Main *)mainlist->first)->library;
-		ID *id = (ID *)lib;
-
-		BLI_addtail(libraries, id);
-		id->us = 1;
-		id->icon_id = 0;
-		*((short *)id->name) = ID_LI;
-		new_id(libraries, id, "Lib");
-	}
-
+	/* Add library datablock itself to 'main' Main, since libraries are **never** linked data.
+	 * Fixes bug where you could end with all ID_LI datablocks having the same name... */
+	lib = BKE_libblock_alloc(mainlist->first, ID_LI, "Lib");
 	BLI_strncpy(lib->name, filepath, sizeof(lib->name));
 	BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
 	
@@ -7949,7 +7937,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
 	if (id->flag & LIB_FAKEUSER) id->us= 1;
 	else id->us = 0;
 	id->icon_id = 0;
-	id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA|LIB_DOIT|LIB_MISSING);
+	id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA | LIB_DOIT | LIB_MISSING);
 	
 	/* this case cannot be direct_linked: it's just the ID part */
 	if (bhead->code == ID_ID) {
@@ -9627,13 +9615,13 @@ static void give_base_to_groups(
 	}
 }
 
-static ID *create_placeholder(Main *mainvar, const short idcode, const char *name, const short flag)
+static ID *create_placeholder(Main *mainvar, const char *idname, const short flag)
 {
+	const short idcode = GS(idname);
 	ListBase *lb = which_libbase(mainvar, idcode);
 	ID *ph_id = BKE_libblock_alloc_notest(idcode);
 
-	*((short *)ph_id->name) = idcode;
-	memcpy(ph_id->name + 2, name, sizeof(ph_id->name) - 2);
+	memcpy(ph_id->name, idname, sizeof(ph_id->name));
 	BKE_libblock_init_empty(ph_id);
 	ph_id->lib = mainvar->curlib;
 	ph_id->flag = flag | LIB_MISSING;
@@ -9812,9 +9800,9 @@ static void link_id_part(ReportList *reports, FileData *fd, Main *mainvar, ID *i
 				mainvar->curlib->filepath,
 				library_parent_filepath(mainvar->curlib));
 
-		/* Generate a placeholder for this ID (limited version of read_libblock actually...). */
+		/* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
 		if (r_id) {
-			*r_id = create_placeholder(mainvar, GS(id->name), id->name + 2, id->flag);
+			*r_id = create_placeholder(mainvar, id->name, id->flag);
 		}
 	}
 }




More information about the Bf-blender-cvs mailing list