[Bf-blender-cvs] [3f725f10ccf] master: Fix T68647: objects cannot be moved to collection if there is no active object

Philipp Oeser noreply at git.blender.org
Mon Aug 19 14:53:53 CEST 2019


Commit: 3f725f10ccffd546c3c7a1cad24d7694c64a4ba7
Author: Philipp Oeser
Date:   Mon Aug 19 14:45:07 2019 +0200
Branches: master
https://developer.blender.org/rB3f725f10ccffd546c3c7a1cad24d7694c64a4ba7

Fix T68647: objects cannot be moved to collection if there is no active
object

This showed e.g. when deleting active object, then selecting using box
select.
This commit also lifts the restriction that linked objects could not be
moved to a collection.

Reviewers: campbellbarton, dfelinto

Maniphest Tasks: T68647

Differential Revision: https://developer.blender.org/D5485

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

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

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

diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index ed40a4eb948..16d21a11e2b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -116,6 +116,7 @@
 typedef struct MoveToCollectionData MoveToCollectionData;
 static void move_to_collection_menus_items(struct uiLayout *layout,
                                            struct MoveToCollectionData *menu);
+static ListBase selected_objects_get(bContext *C);
 
 /* ************* XXX **************** */
 static void error(const char *UNUSED(arg))
@@ -1460,6 +1461,23 @@ void OBJECT_OT_mode_set_or_submode(wmOperatorType *ot)
   RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
 
+static ListBase selected_objects_get(bContext *C)
+{
+  ListBase objects = {NULL};
+
+  if (CTX_wm_space_outliner(C) != NULL) {
+    ED_outliner_selected_objects_get(C, &objects);
+  }
+  else {
+    CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
+      BLI_addtail(&objects, BLI_genericNodeN(ob));
+    }
+    CTX_DATA_END;
+  }
+
+  return objects;
+}
+
 static bool move_to_collection_poll(bContext *C)
 {
   if (CTX_wm_space_outliner(C) != NULL) {
@@ -1472,7 +1490,7 @@ static bool move_to_collection_poll(bContext *C)
       return false;
     }
 
-    return ED_operator_object_active_editable(C);
+    return ED_operator_objectmode(C);
   }
 }
 
@@ -1498,15 +1516,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
     return OPERATOR_CANCELLED;
   }
 
-  if (CTX_wm_space_outliner(C) != NULL) {
-    ED_outliner_selected_objects_get(C, &objects);
-  }
-  else {
-    CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
-      BLI_addtail(&objects, BLI_genericNodeN(ob));
-    }
-    CTX_DATA_END;
-  }
+  objects = selected_objects_get(C);
 
   if (is_new) {
     char new_collection_name[MAX_NAME];
@@ -1650,6 +1660,13 @@ static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent
 {
   Scene *scene = CTX_data_scene(C);
 
+  ListBase objects = selected_objects_get(C);
+  if (BLI_listbase_is_empty(&objects)) {
+    BKE_report(op->reports, RPT_ERROR, "No objects selected");
+    return OPERATOR_CANCELLED;
+  }
+  BLI_freelistN(&objects);
+
   /* Reset the menus data for the current master collection, and free previously allocated data. */
   move_to_collection_menus_free(&master_collection_menu);



More information about the Bf-blender-cvs mailing list