Commit: bb95609fcee0c6dae2c6a2a79c5a1506d453e106
Author: Bastien Montagne
Date:   Wed Oct 12 11:45:25 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBbb95609fcee0c6dae2c6a2a79c5a1506d453e106

Fix T101679: Duplicate objects are created when 'Make' override is called on 
existing override in 3DView

When the active selected object in the 3DView is already a local
liboverride, only perform the 'clear system flag' process on selected
objects, there is no point in trying to create an override out of it.

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

M       source/blender/editors/object/object_relations.c

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

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index a33cc60cddc..3c063c6923f 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2313,26 +2313,39 @@ static int make_override_library_exec(bContext *C, 
wmOperator *op)
     id_root = &collection->id;
     user_overrides_from_selected_objects = true;
   }
-  /* Else, poll func ensures us that ID_IS_LINKED(obact) is true. */
+  /* Else, poll func ensures us that ID_IS_LINKED(obact) is true, or that it 
is already an existing
+   * liboverride. */
   else {
+    BLI_assert(ID_IS_LINKED(obact) || ID_IS_OVERRIDE_LIBRARY_REAL(obact));
     id_root = &obact->id;
     user_overrides_from_selected_objects = true;
   }
 
-  const bool do_fully_editable = !user_overrides_from_selected_objects;
-
-  GSet *user_overrides_objects_uids = do_fully_editable ? NULL :
-                                                          
BLI_gset_new(BLI_ghashutil_inthash_p,
-                                                                       
BLI_ghashutil_intcmp,
-                                                                       
__func__);
-
   /* Make already existing selected liboverrides editable. */
+  bool is_active_override = false;
   FOREACH_SELECTED_OBJECT_BEGIN (view_layer, CTX_wm_view3d(C), ob_iter) {
     if (ID_IS_OVERRIDE_LIBRARY_REAL(ob_iter) && !ID_IS_LINKED(ob_iter)) {
       ob_iter->id.override_library->flag &= 
~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
+      is_active_override = is_active_override || (&ob_iter->id == id_root);
+      DEG_id_tag_update(&ob_iter->id, ID_RECALC_COPY_ON_WRITE);
     }
   }
   FOREACH_SELECTED_OBJECT_END;
+  /* If the active object is a liboverride, there is no point going further, 
since in the weird
+   * case where some other selected objects would be linked ones, there is no 
way to properly
+   * create overrides for them currently.
+   *
+   * Could be added later if really needed, but would rather avoid that extra 
complexity here. */
+  if (is_active_override) {
+    return OPERATOR_FINISHED;
+  }
+
+  const bool do_fully_editable = !user_overrides_from_selected_objects;
+
+  GSet *user_overrides_objects_uids = do_fully_editable ? NULL :
+                                                          
BLI_gset_new(BLI_ghashutil_inthash_p,
+                                                                       
BLI_ghashutil_intcmp,
+                                                                       
__func__);
 
   if (do_fully_editable) {
     /* Pass. */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to