[Bf-blender-cvs] [6fde0050c45] master: Fix (unreported) LibOverride: RNA asserts when applying overrides.
Bastien Montagne
noreply at git.blender.org
Wed Sep 23 11:07:43 CEST 2020
Commit: 6fde0050c45af994d7f0de16622037bf28c938c8
Author: Bastien Montagne
Date: Tue Sep 22 18:18:52 2020 +0200
Branches: master
https://developer.blender.org/rB6fde0050c45af994d7f0de16622037bf28c938c8
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.
===================================================================
M source/blender/blenkernel/intern/lib_override.c
===================================================================
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;
}
/**
More information about the Bf-blender-cvs
mailing list