Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-12-17 14:03:34 +0300
committerBastien Montagne <bastien@blender.org>2020-12-17 14:05:30 +0300
commitcf2ebaf27c78b3f8f79d9d014ca2261228f87e70 (patch)
tree760a0598385dbeae24c764f3d79fb9338312d21a
parent0eedba328df3cbc326900c34cdfc39b8554ad5ec (diff)
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.
-rw-r--r--source/blender/blenkernel/intern/lib_override.c6
-rw-r--r--source/blender/editors/object/object_relations.c11
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c13
3 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 11544d83ba9..cabc80d4024 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -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.
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 8ec9f7af184..5caa7c71e83 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -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) {
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index e4c3ebfdff5..492fc5c23bc 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -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);