diff options
author | Bastien Montagne <bastien@blender.org> | 2020-09-22 19:18:52 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-09-23 12:07:03 +0300 |
commit | 6fde0050c45af994d7f0de16622037bf28c938c8 (patch) | |
tree | 888e6d9a0f6956c0d2c3ad21b81288124c68acb2 /source/blender/blenkernel | |
parent | b93b75b5fb716979f88abbc6aedc778c3509e2b5 (diff) |
Fix (unreported) LibOverride: RNA asserts when applying overrides.
Some RNA setters require ID data they operate on to be in G_MAIN.
Unfortunately, when we apply overrides as part of a .blend file reading,
new Main is not yet made global one, so we have to do it temporarily
here.
This is a fairly ugly hack, but it should be harmless and safe.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/lib_override.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index befb4afc0b7..d7ccef3c0e7 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -37,6 +37,7 @@ #include "BKE_armature.h" #include "BKE_collection.h" +#include "BKE_global.h" #include "BKE_idtype.h" #include "BKE_key.h" #include "BKE_layer.h" @@ -1724,12 +1725,20 @@ void BKE_lib_override_library_main_update(Main *bmain) { ID *id; + /* This temporary swap of G_MAIN is rather ugly, but neessary to avoid asserts checks in some RNA + * assignement functions, since those always use on G_MAIN when they need acces to a Main + * database. */ + Main *orig_gmain = G_MAIN; + G_MAIN = bmain; + FOREACH_MAIN_ID_BEGIN (bmain, id) { if (id->override_library != NULL && id->lib == NULL) { BKE_lib_override_library_update(bmain, id); } } FOREACH_MAIN_ID_END; + + G_MAIN = orig_gmain; } /** |