Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-01 22:25:13 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-01 22:25:13 +0400
commit5adcf774ba50c3561728e3e9b24448aed798c248 (patch)
tree2390f1a7f9c81f2663248acad032e86c40b62c80 /source/blender/makesrna/intern/rna_mesh.c
parentd7ce201e6a78658c04ebcc29bad710863f587d52 (diff)
Fix #30045: mesh.uv_textures.new() not returning correct layer when a layer with
the requested name already exists.
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c52
1 files changed, 34 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 2ada09f2df1..c2faf20749d 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -1132,22 +1133,25 @@ static int rna_Mesh_tot_face_get(PointerRNA *ptr)
return me->edit_mesh ? me->edit_mesh->totfacesel : 0;
}
-static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name)
+static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name)
{
+ PointerRNA ptr;
CustomData *fdata;
CustomDataLayer *cdl= NULL;
- int index;
+ int index= ED_mesh_color_add(C, NULL, NULL, me, name, FALSE);
- if(ED_mesh_color_add(C, NULL, NULL, me, name, FALSE)) {
+ if(index != -1) {
fdata= rna_mesh_fdata(me);
- index= CustomData_get_named_layer_index(fdata, CD_MCOL, name);
- cdl= (index == -1)? NULL: &fdata->layers[index];
+ cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MCOL, index)];
}
- return cdl;
+
+ RNA_pointer_create(&me->id, &RNA_MeshColorLayer, cdl, &ptr);
+ return ptr;
}
-static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
+static PointerRNA rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
{
+ PointerRNA ptr;
CustomDataLayer *cdl = NULL;
int index;
@@ -1156,11 +1160,13 @@ static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bConte
cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
- return cdl;
+ RNA_pointer_create(&me->id, &RNA_MeshIntPropertyLayer, cdl, &ptr);
+ return ptr;
}
-static CustomDataLayer *rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name)
+static PointerRNA rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name)
{
+ PointerRNA ptr;
CustomDataLayer *cdl = NULL;
int index;
@@ -1169,11 +1175,13 @@ static CustomDataLayer *rna_Mesh_float_property_new(struct Mesh *me, struct bCon
cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
- return cdl;
+ RNA_pointer_create(&me->id, &RNA_MeshFloatPropertyLayer, cdl, &ptr);
+ return ptr;
}
-static CustomDataLayer *rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name)
+static PointerRNA rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name)
{
+ PointerRNA ptr;
CustomDataLayer *cdl = NULL;
int index;
@@ -1182,21 +1190,24 @@ static CustomDataLayer *rna_Mesh_string_property_new(struct Mesh *me, struct bCo
cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
- return cdl;
+ RNA_pointer_create(&me->id, &RNA_MeshStringPropertyLayer, cdl, &ptr);
+ return ptr;
}
-static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
+static PointerRNA rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
{
+ PointerRNA ptr;
CustomData *fdata;
CustomDataLayer *cdl= NULL;
- int index;
+ int index= ED_mesh_uv_texture_add(C, me, name, FALSE);
- if(ED_mesh_uv_texture_add(C, me, name, FALSE)) {
+ if(index != -1) {
fdata= rna_mesh_fdata(me);
- index= CustomData_get_named_layer_index(fdata, CD_MTFACE, name);
- cdl= (index == -1)? NULL: &fdata->layers[index];
+ cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MTFACE, index)];
}
- return cdl;
+
+ RNA_pointer_create(&me->id, &RNA_MeshTextureFaceLayer, cdl, &ptr);
+ return ptr;
}
#else
@@ -1783,6 +1794,7 @@ static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh");
RNA_def_string(func, "name", "Col", 0, "", "Vertex color name");
parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer");
+ RNA_def_property_flag(parm, PROP_RNAPTR);
RNA_def_function_return(func, parm);
/*
@@ -1823,6 +1835,7 @@ static void rna_def_int_layers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a integer property layer to Mesh");
RNA_def_string(func, "name", "Int Prop", 0, "", "Int property name");
parm= RNA_def_pointer(func, "layer", "MeshIntPropertyLayer", "", "The newly created layer");
+ RNA_def_property_flag(parm, PROP_RNAPTR);
RNA_def_function_return(func, parm);
}
@@ -1844,6 +1857,7 @@ static void rna_def_float_layers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
RNA_def_string(func, "name", "Float Prop", 0, "", "Float property name");
parm= RNA_def_pointer(func, "layer", "MeshFloatPropertyLayer", "", "The newly created layer");
+ RNA_def_property_flag(parm, PROP_RNAPTR);
RNA_def_function_return(func, parm);
}
@@ -1865,6 +1879,7 @@ static void rna_def_string_layers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a string property layer to Mesh");
RNA_def_string(func, "name", "String Prop", 0, "", "String property name");
parm= RNA_def_pointer(func, "layer", "MeshStringPropertyLayer", "", "The newly created layer");
+ RNA_def_property_flag(parm, PROP_RNAPTR);
RNA_def_function_return(func, parm);
}
@@ -1887,6 +1902,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh");
RNA_def_string(func, "name", "UVMap", 0, "", "UV map name");
parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer");
+ RNA_def_property_flag(parm, PROP_RNAPTR);
RNA_def_function_return(func, parm);
/*