Fix T83875: Converting Proxy to override crashes blender.
Some weird proxies apparently can have a local collection instancing... Not sure this is even really valid for proxies, but in any case we cannot override that, just detect and properly cancel the operation then. Should be backported to 2.91.1 should we do it.
This commit is contained in:
parent
0eedba328d
commit
cf2ebaf27c
Notes:
blender-bot
2023-02-14 04:10:15 +01:00
Referenced by issue #83875, Converting Proxy to override crashes blender Referenced by issue #83216, Potential candidates for corrective releases
|
@ -702,6 +702,12 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain,
|
|||
&ob_proxy->proxy->id;
|
||||
ID *id_reference = is_override_instancing_object ? &ob_proxy_group->id : &ob_proxy->id;
|
||||
|
||||
/* In some cases the instance collection of a proxy object may be local (see e.g. T83875). Not
|
||||
* sure this is a valid state, but for now just abort the overriding process. */
|
||||
if (!ID_IS_OVERRIDABLE_LIBRARY(id_root)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* We manually convert the proxy object into a library override, further override handling will
|
||||
* then be handled by `BKE_lib_override_library_create()` just as for a regular override
|
||||
* creation.
|
||||
|
|
|
@ -2527,7 +2527,7 @@ static bool convert_proxy_to_override_poll(bContext *C)
|
|||
return obact != NULL && obact->proxy != NULL;
|
||||
}
|
||||
|
||||
static int convert_proxy_to_override_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int convert_proxy_to_override_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
@ -2541,6 +2541,15 @@ static int convert_proxy_to_override_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
const bool success = BKE_lib_override_library_proxy_convert(bmain, scene, view_layer, ob_proxy);
|
||||
|
||||
if (!success) {
|
||||
BKE_reportf(
|
||||
op->reports,
|
||||
RPT_ERROR_INVALID_INPUT,
|
||||
"Could not create a library override from proxy '%s' (might use already local data?)",
|
||||
ob_proxy->id.name + 2);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* Remove the instance empty from this scene, the items now have an overridden collection
|
||||
* instead. */
|
||||
if (success && is_override_instancing_object) {
|
||||
|
|
|
@ -737,7 +737,7 @@ static void id_local_fn(bContext *C,
|
|||
}
|
||||
|
||||
static void object_proxy_to_override_convert_fn(bContext *C,
|
||||
ReportList *UNUSED(reports),
|
||||
ReportList *reports,
|
||||
Scene *UNUSED(scene),
|
||||
TreeElement *UNUSED(te),
|
||||
TreeStoreElem *UNUSED(tsep),
|
||||
|
@ -754,8 +754,15 @@ static void object_proxy_to_override_convert_fn(bContext *C,
|
|||
return;
|
||||
}
|
||||
|
||||
BKE_lib_override_library_proxy_convert(
|
||||
CTX_data_main(C), scene, CTX_data_view_layer(C), ob_proxy);
|
||||
if (!BKE_lib_override_library_proxy_convert(
|
||||
CTX_data_main(C), scene, CTX_data_view_layer(C), ob_proxy)) {
|
||||
BKE_reportf(
|
||||
reports,
|
||||
RPT_ERROR_INVALID_INPUT,
|
||||
"Could not create a library override from proxy '%s' (might use already local data?)",
|
||||
ob_proxy->id.name + 2);
|
||||
return;
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS | ID_RECALC_COPY_ON_WRITE);
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
|
|
Loading…
Reference in New Issue