From 39e0bbfa5518bb2d9d2dcff8a9fa12483c66571f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 6 Feb 2023 17:31:01 +0100 Subject: [PATCH] BKE libquery: Add option to also process `ID.lib` pointer. This was never needed before, but upcomming work for Brush Asset project requires it. --- source/blender/blenkernel/BKE_lib_query.h | 3 +++ source/blender/blenkernel/intern/lib_query.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_lib_query.h b/source/blender/blenkernel/BKE_lib_query.h index 69e8f58178a..fc538cba221 100644 --- a/source/blender/blenkernel/BKE_lib_query.h +++ b/source/blender/blenkernel/BKE_lib_query.h @@ -142,6 +142,9 @@ enum { /** Also process internal ID pointers like `ID.newid` or `ID.orig_id`. * WARNING: Dangerous, use with caution. */ IDWALK_DO_INTERNAL_RUNTIME_POINTERS = (1 << 9), + /** Also process the ID.lib pointer. It is an option because this pointer can usually be fully + ignored. */ + IDWALK_DO_LIBRARY_POINTER = (1 << 10), }; typedef struct LibraryForeachIDData LibraryForeachIDData; diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index e655ae88c30..124ba21d406 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -294,8 +294,9 @@ static bool library_foreach_ID_link(Main *bmain, continue; } - /* NOTE: ID.lib pointer is purposefully fully ignored here... - * We may want to add it at some point? */ + if (flag & IDWALK_DO_LIBRARY_POINTER) { + CALLBACK_INVOKE(id->lib, IDWALK_CB_NEVER_SELF); + } if (flag & IDWALK_DO_INTERNAL_RUNTIME_POINTERS) { CALLBACK_INVOKE_ID(id->newid, IDWALK_CB_INTERNAL);