Fix T100203: Freeze using `override_hierarchy_create` with Object level property with custom getter function.

As suggested by @brecht, use the `BPy_BEGIN`/`END_ALLOW_THREADS` macros.

Note that there may be other bits of code needing this too.
This commit is contained in:
Bastien Montagne 2022-08-12 16:19:09 +02:00
parent 515a15f200
commit 62eb21e3ce
Notes: blender-bot 2023-02-14 08:49:53 +01:00
Referenced by issue #100203, Freeze using `override_hierarchy_create` with Object level property with custom getter function
1 changed files with 23 additions and 1 deletions

View File

@ -234,6 +234,10 @@ const struct IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = {
# include "WM_api.h"
# ifdef WITH_PYTHON
# include "BPY_extern.h"
# endif
void rna_ID_override_library_property_operation_refname_get(PointerRNA *ptr, char *value)
{
IDOverrideLibraryPropertyOperation *opop = ptr->data;
@ -695,7 +699,16 @@ static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages)
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, true);
}
ID *local_id = BKE_lib_override_library_create_from_id(bmain, id, remap_local_usages);
ID *local_id = NULL;
# ifdef WITH_PYTHON
BPy_BEGIN_ALLOW_THREADS;
# endif
local_id = BKE_lib_override_library_create_from_id(bmain, id, remap_local_usages);
# ifdef WITH_PYTHON
BPy_END_ALLOW_THREADS;
# endif
if (remap_local_usages) {
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
@ -717,9 +730,18 @@ static ID *rna_ID_override_hierarchy_create(
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
ID *id_root_override = NULL;
# ifdef WITH_PYTHON
BPy_BEGIN_ALLOW_THREADS;
# endif
BKE_lib_override_library_create(
bmain, scene, view_layer, NULL, id, id, id_instance_hint, &id_root_override, false);
# ifdef WITH_PYTHON
BPy_END_ALLOW_THREADS;
# endif
WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
WM_main_add_notifier(NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL);