[Bf-blender-cvs] [aaea263be4d] master: Cleanup: Fix const correctness in CustomData set name function

Hans Goudey noreply at git.blender.org
Fri Aug 26 18:03:36 CEST 2022


Commit: aaea263be4d0ffc5b23ac5752a1d15d31eb9c7ca
Author: Hans Goudey
Date:   Fri Aug 26 10:57:35 2022 -0500
Branches: master
https://developer.blender.org/rBaaea263be4d0ffc5b23ac5752a1d15d31eb9c7ca

Cleanup: Fix const correctness in CustomData set name function

The function does modify the object since it changes the name of a layer
it owns. Ideally this wouldn't be possible, but raw pointers don't have
ownership semantics so this is a common problem with CustomData.

===================================================================

M	source/blender/blenkernel/BKE_customdata.h
M	source/blender/blenkernel/intern/customdata.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 6461ff30cd6..1ba0373f194 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -417,7 +417,7 @@ void *CustomData_bmesh_get_n(const struct CustomData *data, void *block, int typ
  */
 void *CustomData_bmesh_get_layer_n(const struct CustomData *data, void *block, int n);
 
-bool CustomData_set_layer_name(const struct CustomData *data, int type, int n, const char *name);
+bool CustomData_set_layer_name(struct CustomData *data, int type, int n, const char *name);
 const char *CustomData_get_layer_name(const struct CustomData *data, int type, int n);
 
 /**
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 90bc79f6907..6d89e1621d5 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -3537,10 +3537,7 @@ int CustomData_get_offset_named(const CustomData *data, int type, const char *na
   return data->layers[layer_index].offset;
 }
 
-bool CustomData_set_layer_name(const CustomData *data,
-                               const int type,
-                               const int n,
-                               const char *name)
+bool CustomData_set_layer_name(CustomData *data, const int type, const int n, const char *name)
 {
   /* get the layer index of the first layer of type */
   const int layer_index = CustomData_get_layer_index_n(data, type, n);



More information about the Bf-blender-cvs mailing list