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
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/object/object_edit.c37
1 files changed, 27 insertions, 10 deletions
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);