[Bf-blender-cvs] [614a0a47e59] master: BKE_main: make FOREACH new macros working when deleting some IDs.

Bastien Montagne noreply at git.blender.org
Mon Feb 18 17:16:44 CET 2019


Commit: 614a0a47e59a648a3bb7ba7b55b417a5faa730ba
Author: Bastien Montagne
Date:   Mon Feb 18 15:45:52 2019 +0100
Branches: master
https://developer.blender.org/rB614a0a47e59a648a3bb7ba7b55b417a5faa730ba

BKE_main: make FOREACH new macros working when deleting some IDs.

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

M	source/blender/blenkernel/BKE_main.h

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

diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 6821ec1c5ee..cd17d84651c 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -143,9 +143,13 @@ struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset);
 /* *** Generic utils to loop over whole Main database. *** */
 
 #define FOREACH_MAIN_LISTBASE_ID_BEGIN(_lb, _id)                          \
-	for (_id = _lb->first; _id != NULL; _id = _id->next) {                \
+	{                                                                     \
+		ID *_id_next = _lb->first;                                        \
+		for (_id = _id_next; _id != NULL; _id = _id_next) {               \
+			_id_next = _id->next;
 
 #define FOREACH_MAIN_LISTBASE_ID_END                                      \
+		}                                                                 \
 	} ((void)0)
 
 
@@ -154,7 +158,7 @@ struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset);
 		ListBase *_lbarray[MAX_LIBARRAY];                                 \
 		int i = set_listbasepointers(_bmain, _lbarray);                   \
 		while (i--) {                                                     \
-			FOREACH_MAIN_LISTBASE_ID_BEGIN(_lbarray[i], _id)              \
+			FOREACH_MAIN_LISTBASE_ID_BEGIN(_lbarray[i], _id)
 
 #define FOREACH_MAIN_ID_END                                               \
 			FOREACH_MAIN_LISTBASE_ID_END;                                 \



More information about the Bf-blender-cvs mailing list