From fd4c01a75c34fa88a20d3967d02996c0c9815efe Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 12 Mar 2021 09:39:23 +0100 Subject: LibQuery: Add an option to process internal runtime ID pointers. In some cases (advanced, low-level code) we also want to process ID pointers like `ID.newid` or `ID.orig_id`. --- source/blender/blenkernel/intern/lib_query.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/lib_query.c') diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index acd0c10040c..e33743eb36b 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -183,8 +183,9 @@ static void library_foreach_ID_link(Main *bmain, BLI_assert(inherit_data == NULL || data.bmain == inherit_data->bmain); if (flag & IDWALK_RECURSE) { - /* For now, recursion implies read-only. */ + /* For now, recursion implies read-only, and no internal pointers. */ flag |= IDWALK_READONLY; + flag &= ~IDWALK_DO_INTERNAL_RUNTIME_POINTERS; data.ids_handled = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); BLI_LINKSTACK_INIT(data.ids_todo); @@ -230,6 +231,7 @@ static void library_foreach_ID_link(Main *bmain, } if (bmain != NULL && bmain->relations != NULL && (flag & IDWALK_READONLY) && + (flag & IDWALK_DO_INTERNAL_RUNTIME_POINTERS) == 0 && (((bmain->relations->flag & MAINIDRELATIONS_INCLUDE_UI) == 0) == ((data.flag & IDWALK_INCLUDE_UI) == 0))) { /* Note that this is minor optimization, even in worst cases (like id being an object with @@ -250,6 +252,11 @@ static void library_foreach_ID_link(Main *bmain, /* Note: ID.lib pointer is purposefully fully ignored here... * We may want to add it at some point? */ + if (flag & IDWALK_DO_INTERNAL_RUNTIME_POINTERS) { + CALLBACK_INVOKE_ID(id->newid, IDWALK_CB_INTERNAL); + CALLBACK_INVOKE_ID(id->orig_id, IDWALK_CB_INTERNAL); + } + if (id->override_library != NULL) { CALLBACK_INVOKE_ID(id->override_library->reference, IDWALK_CB_USER | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE); -- cgit v1.2.3