Fix: Skip anonymous CustomData layers for the python API #104783

Merged
Martijn Versteegh merged 5 commits from Baardaap/blender:skipanonymousuvlayers into main 2023-02-15 23:55:01 +01:00
1 changed files with 6 additions and 6 deletions
Showing only changes of commit ecbf269d7f - Show all commits

View File

@ -2982,8 +2982,8 @@ int CustomData_number_of_layers(const CustomData *data, const int type)
{
int number = 0;
for (const CustomDataLayer &layer : Span(data->layers, data->totlayer)) {
if (layer.type == type) {
for (int i = 0; i < data->totlayer; i++) {
Review

Better to leave these cleanups out IMO, and not mix cleaning up existing code with a bug fix.

Better to leave these cleanups out IMO, and not mix cleaning up existing code with a bug fix.

Hm, I have some mental problems to use the modern syntax for the new function, but leave the two analogous ones directly below it in the old synax.

Then I'd prefer to use the same (old) syntax for the new function.

Hm, I have some mental problems to use the modern syntax for the new function, but leave the two analogous ones directly below it in the old synax. Then I'd prefer to use the same (old) syntax for the new function.
Review

That's fine too. The more important part is not mixing cleanups with fixes too much.

That's fine too. The more important part is not mixing cleanups with fixes too much.
if (data->layers[i].type == type) {
number++;
}
}
@ -2995,8 +2995,8 @@ int CustomData_number_of_anonymous_layers(const CustomData *data, const int type
{
int number = 0;
for (const CustomDataLayer &layer : Span(data->layers, data->totlayer)) {
if (layer.type == type && layer.anonymous_id != nullptr) {
for (int i = 0; i < data->totlayer; i++) {
Review

How about for (const CustomDataLayer &layer : Span(data->layers, data->totlayer)) {?

How about `for (const CustomDataLayer &layer : Span(data->layers, data->totlayer)) {`?

Can do, but then maybe change CustomData_get_number_of_layers() as well?

Can do, but then maybe change CustomData_get_number_of_layers() as well?
Review

Mainly I just think new code should be "clean", even if slightly inconsistent with the surrounding area. Cleaning up existing code is another task.

Mainly I just think new code should be "clean", even if slightly inconsistent with the surrounding area. Cleaning up existing code is another task.
if (data->layers[i].type == type && data->layers[i].anonymous_id != nullptr) {
number++;
}
}
@ -3009,8 +3009,8 @@ int CustomData_number_of_layers_typemask(const CustomData *data, const eCustomDa
{
int number = 0;
for (const CustomDataLayer &layer : Span(data->layers, data->totlayer)) {
if (mask & CD_TYPE_AS_MASK(layer.type)) {
for (int i = 0; i < data->totlayer; i++) {
if (mask & CD_TYPE_AS_MASK(data->layers[i].type)) {
number++;
}
}