Page MenuHome

Fix T68647: objects selected using box select cannot be moved to collection if there is no active object
ClosedPublic

Authored by Philipp Oeser (lichtwerk) on Wed, Aug 14, 8:23 PM.

Details

Summary

question is also if we really need to exlude linked objects from this
(see code comments)? ED_operator_object_active_editable would have done
this...

Diff Detail

Repository
rB Blender

Event Timeline

Dalai Felinto (dfelinto) requested changes to this revision.Wed, Aug 14, 8:41 PM

First, I agree that it should be no restriction to moving linked objects to collections (note that 2.79 did not have this restrictions to move them to layers).

Now, why not to simply replace it with ED_operator_object_active()?

This revision now requires changes to proceed.Wed, Aug 14, 8:41 PM

First, I agree that it should be no restriction to moving linked objects to collections (note that 2.79 did not have this restrictions to move them to layers).
Now, why not to simply replace it with ED_operator_object_active()?

because there might be selected objects (but no active one), e.g. if you delete the active object and then box-select objects, see T68647.
ED_operator_object_active will return false here... (and I dont think we should be preventing Move To Collection in that case?)

Campbell Barton (campbellbarton) requested changes to this revision.Fri, Aug 16, 1:13 PM
Campbell Barton (campbellbarton) added inline comments.
source/blender/editors/object/object_edit.c
1666

move_to_collection_exec does this:

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;
}

Suggest turning this into a function and sharing between invoke & exec.

  • use shared function
Philipp Oeser (lichtwerk) marked an inline comment as done.Fri, Aug 16, 1:49 PM

I think there are plenty of places in Blender where no active objects lead to the operator poll to fail. But I'm glad we are slowing changing that.
We even have the case where we need an active object for the poll, yet if the active object is not selected, it may not be affected by the operator.

Anyways, the patch needs cleanup, despite that it should be fine.

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

Please follow the codestyle here: Comments always start with a capital letter:

- /* prior to changing ...
+ /* Prior to changing ...

That said this comment can be removed.

1667

Please use the BLI_listbase_is_empty instead.

1671

Please cleanup the patch from commented out code.

This revision is now accepted and ready to land.Fri, Aug 16, 8:23 PM

I think there are plenty of places in Blender where no active objects lead to the operator poll to fail. But I'm glad we are slowing changing that.

This patch applies to invoke, if we want poll to take object selection into account we should have a way to check this without poll having to count object selection every check, eg: check scene statistics in a reliable way (not sure if they're guaranteed to be up to date at the moment, if status bar isn't displayed for e.g. or when a script calls multiple operators at once).