[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55150] trunk/blender/source: patch [ #34103] check_for_dupid.patch

Campbell Barton ideasman42 at gmail.com
Sun Mar 10 06:46:26 CET 2013


Revision: 55150
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55150
Author:   campbellbarton
Date:     2013-03-10 05:46:24 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
patch [#34103] check_for_dupid.patch
from Lawrence D'Oliveiro (ldo)

- more comments
- more uses of bool type
- define symbol for length of in_use array in check_for_dupid

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_animsys.h
    trunk/blender/source/blender/blenkernel/BKE_library.h
    trunk/blender/source/blender/blenkernel/intern/anim_sys.c
    trunk/blender/source/blender/blenkernel/intern/blender.c
    trunk/blender/source/blender/blenkernel/intern/library.c
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/blenloader/intern/versioning_250.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/object/object_relations.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/editors/space_outliner/outliner_tools.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/makesrna/intern/rna_ID.c
    trunk/blender/source/blender/python/intern/bpy_library.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c
    trunk/blender/source/gameengine/GameLogic/SCA_IActuator.h

Modified: trunk/blender/source/blender/blenkernel/BKE_animsys.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_animsys.h	2013-03-10 05:19:29 UTC (rev 55149)
+++ trunk/blender/source/blender/blenkernel/BKE_animsys.h	2013-03-10 05:46:24 UTC (rev 55150)
@@ -63,10 +63,10 @@
 void BKE_free_animdata(struct ID *id);
 
 /* Copy AnimData */
-struct AnimData *BKE_copy_animdata(struct AnimData *adt, const short do_action);
+struct AnimData *BKE_copy_animdata(struct AnimData *adt, const bool do_action);
 
 /* Copy AnimData */
-int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const short do_action);
+int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const bool do_action);
 
 /* Copy AnimData Actions */
 void BKE_copy_animdata_id_action(struct ID *id);

Modified: trunk/blender/source/blender/blenkernel/BKE_library.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_library.h	2013-03-10 05:19:29 UTC (rev 55149)
+++ trunk/blender/source/blender/blenkernel/BKE_library.h	2013-03-10 05:46:24 UTC (rev 55150)
@@ -63,7 +63,7 @@
 __attribute__((nonnull))
 #endif
 ;
-void  BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const short do_action);
+void  BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool do_action);
 
 void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
 void id_lib_extern(struct ID *id);
@@ -72,13 +72,13 @@
 void id_us_plus(struct ID *id);
 void id_us_min(struct ID *id);
 
-int id_make_local(struct ID *id, int test);
-int id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
-int id_copy(struct ID *id, struct ID **newid, int test);
-int id_unlink(struct ID *id, int test);
+bool id_make_local(struct ID *id, bool test);
+bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
+bool id_copy(struct ID *id, struct ID **newid, bool test);
+bool id_unlink(struct ID *id, int test);
 void id_sort_by_name(struct ListBase *lb, struct ID *id);
 
-int new_id(struct ListBase *lb, struct ID *id, const char *name);
+bool new_id(struct ListBase *lb, struct ID *id, const char *name);
 void id_clear_lib_data(struct Main *bmain, struct ID *id);
 
 struct ListBase *which_libbase(struct Main *mainlib, short type);
@@ -96,10 +96,10 @@
 void tag_main(struct Main *mainvar, const short tag);
 
 void rename_id(struct ID *id, const char *name);
-void name_uiprefix_id(char *name, struct ID *id);
+void name_uiprefix_id(char *name, const struct ID *id);
 void test_idbutton(char *name);
-void text_idbutton(struct ID *id, char *text);
-void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only);
+void text_idbutton(const struct ID *id, char *text);
+void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only);
 struct ID *BKE_libblock_find_name(const short type, const char *name)
 #ifdef __GNUC__
 __attribute__((warn_unused_result))
@@ -128,4 +128,4 @@
 }
 #endif
 
-#endif
+#endif  /* __BKE_LIBRARY_H__ */

Modified: trunk/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2013-03-10 05:19:29 UTC (rev 55149)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2013-03-10 05:46:24 UTC (rev 55150)
@@ -242,7 +242,7 @@
 /* Freeing -------------------------------------------- */
 
 /* Make a copy of the given AnimData - to be used when copying datablocks */
-AnimData *BKE_copy_animdata(AnimData *adt, const short do_action)
+AnimData *BKE_copy_animdata(AnimData *adt, const bool do_action)
 {
 	AnimData *dadt;
 	
@@ -274,7 +274,7 @@
 	return dadt;
 }
 
-int BKE_copy_animdata_id(ID *id_to, ID *id_from, const short do_action)
+int BKE_copy_animdata_id(ID *id_to, ID *id_from, const bool do_action)
 {
 	AnimData *adt;
 

Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c	2013-03-10 05:19:29 UTC (rev 55149)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c	2013-03-10 05:46:24 UTC (rev 55150)
@@ -995,7 +995,7 @@
 	
 	/* append, rather than linking */
 	lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath));
-	BKE_library_make_local(bmain, lib, 1);
+	BKE_library_make_local(bmain, lib, true);
 	
 	/* important we unset, otherwise these object wont
 	 * link into other scenes from this blend file */

Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c	2013-03-10 05:19:29 UTC (rev 55149)
+++ trunk/blender/source/blender/blenkernel/intern/library.c	2013-03-10 05:46:24 UTC (rev 55150)
@@ -171,6 +171,7 @@
 	}
 }
 
+/* decrements the user count for *id. */
 void id_us_min(ID *id)
 {
 	if (id) {
@@ -186,102 +187,108 @@
 	}
 }
 
-int id_make_local(ID *id, int test)
+/* calls the appropriate make_local method for the block, unless test. Returns true
+ * if the block can be made local. */
+bool id_make_local(ID *id, bool test)
 {
 	if (id->flag & LIB_INDIRECT)
-		return 0;
+		return false;
 
 	switch (GS(id->name)) {
 		case ID_SCE:
-			return 0; /* not implemented */
+			return false; /* not implemented */
 		case ID_LI:
-			return 0; /* can't be linked */
+			return false; /* can't be linked */
 		case ID_OB:
 			if (!test) BKE_object_make_local((Object *)id);
-			return 1;
+			return true;
 		case ID_ME:
 			if (!test) {
 				BKE_mesh_make_local((Mesh *)id);
 				BKE_key_make_local(((Mesh *)id)->key);
 			}
-			return 1;
+			return true;
 		case ID_CU:
 			if (!test) {
 				BKE_curve_make_local((Curve *)id);
 				BKE_key_make_local(((Curve *)id)->key);
 			}
-			return 1;
+			return true;
 		case ID_MB:
 			if (!test) BKE_mball_make_local((MetaBall *)id);
-			return 1;
+			return true;
 		case ID_MA:
 			if (!test) BKE_material_make_local((Material *)id);
-			return 1;
+			return true;
 		case ID_TE:
 			if (!test) BKE_texture_make_local((Tex *)id);
-			return 1;
+			return true;
 		case ID_IM:
 			if (!test) BKE_image_make_local((Image *)id);
-			return 1;
+			return true;
 		case ID_LT:
 			if (!test) {
 				BKE_lattice_make_local((Lattice *)id);
 				BKE_key_make_local(((Lattice *)id)->key);
 			}
-			return 1;
+			return true;
 		case ID_LA:
 			if (!test) BKE_lamp_make_local((Lamp *)id);
-			return 1;
+			return true;
 		case ID_CA:
 			if (!test) BKE_camera_make_local((Camera *)id);
-			return 1;
+			return true;
 		case ID_SPK:
 			if (!test) BKE_speaker_make_local((Speaker *)id);
-			return 1;
+			return true;
 		case ID_IP:
-			return 0; /* deprecated */
+			return false; /* deprecated */
 		case ID_KE:
 			if (!test) BKE_key_make_local((Key *)id);
-			return 1;
+			return true;
 		case ID_WO:
 			if (!test) BKE_world_make_local((World *)id);
-			return 1;
+			return true;
 		case ID_SCR:
-			return 0; /* can't be linked */
+			return false; /* can't be linked */
 		case ID_VF:
-			return 0; /* not implemented */
+			return false; /* not implemented */
 		case ID_TXT:
-			return 0; /* not implemented */
+			return false; /* not implemented */
 		case ID_SCRIPT:
-			return 0; /* deprecated */
+			return false; /* deprecated */
 		case ID_SO:
-			return 0; /* not implemented */
+			return false; /* not implemented */
 		case ID_GR:
-			return 0; /* not implemented */
+			return false; /* not implemented */
 		case ID_AR:
 			if (!test) BKE_armature_make_local((bArmature *)id);
-			return 1;
+			return true;
 		case ID_AC:
 			if (!test) BKE_action_make_local((bAction *)id);
-			return 1;
+			return true;
 		case ID_NT:
-			return 0; /* not implemented */
+			return false; /* not implemented */
 		case ID_BR:
 			if (!test) BKE_brush_make_local((Brush *)id);
-			return 1;
+			return true;
 		case ID_PA:
 			if (!test) BKE_particlesettings_make_local((ParticleSettings *)id);
-			return 1;
+			return true;
 		case ID_WM:
-			return 0; /* can't be linked */
+			return false; /* can't be linked */
 		case ID_GD:
-			return 0; /* not implemented */
+			return false; /* not implemented */
 	}
 
-	return 0;
+	return false;
 }
 
-int id_copy(ID *id, ID **newid, int test)
+/**
+ * Invokes the appropriate copy method for the block and returns the result in
+ * newid, unless test. Returns true iff the block can be copied.
+ */
+bool id_copy(ID *id, ID **newid, bool test)
 {
 	if (!test) *newid = NULL;
 
@@ -290,124 +297,124 @@
 	 * - id.us of the new ID is set to 1 */
 	switch (GS(id->name)) {
 		case ID_SCE:
-			return 0; /* can't be copied from here */
+			return false;  /* can't be copied from here */
 		case ID_LI:
-			return 0; /* can't be copied from here */
+			return false;  /* can't be copied from here */
 		case ID_OB:
 			if (!test) *newid = (ID *)BKE_object_copy((Object *)id);
-			return 1;
+			return true;
 		case ID_ME:
 			if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id);
-			return 1;
+			return true;
 		case ID_CU:
 			if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id);
-			return 1;
+			return true;
 		case ID_MB:
 			if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id);
-			return 1;
+			return true;
 		case ID_MA:
 			if (!test) *newid = (ID *)BKE_material_copy((Material *)id);
-			return 1;
+			return true;
 		case ID_TE:
 			if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id);
-			return 1;
+			return true;
 		case ID_IM:
 			if (!test) *newid = (ID *)BKE_image_copy(G.main, (Image *)id);
-			return 1;
+			return true;
 		case ID_LT:
 			if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id);
-			return 1;
+			return true;
 		case ID_LA:
 			if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id);
-			return 1;
+			return true;
 		case ID_SPK:
 			if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id);
-			return 1;
+			return true;
 		case ID_CA:
 			if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id);
-			return 1;
+			return true;
 		case ID_IP:
-			return 0; /* deprecated */
+			return false;  /* deprecated */
 		case ID_KE:
 			if (!test) *newid = (ID *)BKE_key_copy((Key *)id);
-			return 1;
+			return true;
 		case ID_WO:
 			if (!test) *newid = (ID *)BKE_world_copy((World *)id);
-			return 1;
+			return true;
 		case ID_SCR:

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list