[Bf-blender-cvs] [a8998af85d9] blender-v2.91-release: Fix T83875: Converting Proxy to override crashes blender.

Bastien Montagne noreply at git.blender.org
Wed Jan 13 15:08:47 CET 2021


Commit: a8998af85d99a8f0117ed919c500dbdccf0ffd32
Author: Bastien Montagne
Date:   Thu Dec 17 12:03:34 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rBa8998af85d99a8f0117ed919c500dbdccf0ffd32

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.

===================================================================

M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/space_outliner/outliner_tools.c

===================================================================

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index f19ab96588e..aef13173db4 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -687,6 +687,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 de3e5f3d5f9..b317fc2e6de 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2503,7 +2503,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);
@@ -2517,6 +2517,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 cbdeb350ba4..5b330d83a21 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -736,7 +736,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),
@@ -753,8 +753,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);



More information about the Bf-blender-cvs mailing list