diff options
author | Bastien Montagne <mont29> | 2022-10-05 13:55:32 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-10-05 15:26:45 +0300 |
commit | b47a234f98dd7e6e0b53ad96b5b4d278635874d8 (patch) | |
tree | d1bc0efb0e769ba060c472862f2b7d45a96f908b /source/blender/blenkernel/BKE_blender.h | |
parent | 31a4fb42d42af66ce6436803cad6d30173f34245 (diff) |
BKE_Main: Add clear separation between 'temp' mains and global main.
Blender is using more and more temporary Main data-base (historically
for reading linked data, but also now when resyncing liboverrides, for
temp data in asset code, etc.).
This commit aims at making this a bit more formal and defined, by:
* Adding a dedicated flag in Main struct to mark a Main as global.
* Adding some API to replace, or temporarily swap the current global
Main (`G_MAIN`) by another one.
NOTE: Having to temporarily replace `G_MAIN` is a workaround for the
limitation of current RNA, ideally this should be fixed in RNA itself,
but for now at least having an API helps tracking those cases (since
this is potentially risky operation).
This work is also a preparation for more usages of temp mains in the near
future (Asset Brushes and its presets system e.g. will most likely use
temp mains too).
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D15977
Diffstat (limited to 'source/blender/blenkernel/BKE_blender.h')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 940dec2fcd5..1f0919bb3e6 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -11,6 +11,9 @@ extern "C" { #endif +#include "BLI_compiler_attrs.h" + +struct Main; struct UserDef; /** @@ -21,6 +24,16 @@ void BKE_blender_free(void); void BKE_blender_globals_init(void); void BKE_blender_globals_clear(void); +/** Replace current global Main by the given one, freeing existing one. */ +void BKE_blender_globals_main_replace(struct Main *bmain); +/** + * Replace current global Main by the given one, returning the old one. + * + * \warning Advanced, risky workaround addressing the issue that current RNA is not able to process + * correectly non-G_MAIN data, use with (a lot of) care. + */ +struct Main *BKE_blender_globals_main_swap(struct Main *new_gmain); + void BKE_blender_userdef_data_swap(struct UserDef *userdef_a, struct UserDef *userdef_b); void BKE_blender_userdef_data_set(struct UserDef *userdef); void BKE_blender_userdef_data_set_and_free(struct UserDef *userdef); |