Fix: Skip anonymous CustomData layers for the python API #104783
|
@ -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++) {
|
||||
|
||||
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++) {
|
||||
Hans Goudey
commented
How about How about `for (const CustomDataLayer &layer : Span(data->layers, data->totlayer)) {`?
Martijn Versteegh
commented
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?
Hans Goudey
commented
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++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
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.
That's fine too. The more important part is not mixing cleanups with fixes too much.