Fix T80597: Assigning material slot from Python console fails

Regression in 12bc34b0b8, add assert so this doesn't happen again.
This commit is contained in:
Campbell Barton 2020-09-15 11:50:46 +10:00
parent 210c721b4d
commit 61cd0d5bd5
Notes: blender-bot 2023-02-14 03:00:45 +01:00
Referenced by issue #80597, Python operator material_slot_assign() doesn't work in 2.91 alpha
2 changed files with 10 additions and 5 deletions

View File

@ -1710,6 +1710,9 @@ void BKE_view_layer_bases_in_mode_iterator_begin(BLI_Iterator *iter, void *data_
struct ObjectsInModeIteratorData *data = data_in;
Base *base = data->base_active;
/* In this case the result will always be empty, the caller must check for no mode. */
BLI_assert(data->object_mode != 0);
/* when there are no objects */
if (base == NULL) {
iter->valid = false;

View File

@ -194,11 +194,13 @@ Object **ED_object_array_in_mode_or_selected(bContext *C,
/* When in a mode that supports multiple active objects, use "objects in mode"
* instead of the object's selection. */
if ((ob_active != NULL) && (ob_active->mode & (OB_MODE_EDIT | OB_MODE_POSE))) {
objects = BKE_view_layer_array_from_objects_in_mode(
view_layer,
v3d,
r_objects_len,
{.no_dup_data = true, .filter_fn = filter_fn, .filter_userdata = filter_user_data});
objects = BKE_view_layer_array_from_objects_in_mode(view_layer,
v3d,
r_objects_len,
{.object_mode = ob_active->mode,
.no_dup_data = true,
.filter_fn = filter_fn,
.filter_userdata = filter_user_data});
}
else {
objects = BKE_view_layer_array_selected_objects(