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:
authorCampbell Barton <ideasman42@gmail.com>2012-11-02 13:41:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-02 13:41:26 +0400
commita31449edaddc1be80676c77babf079a9f137c42d (patch)
tree30bf1759a51f5def43dc000d6af7112642404770 /source/blender/makesrna/intern/rna_color.c
parent2944d42c262d9d4459e356dc8b8fbad1c53c2054 (diff)
all remove functions now invalidate the RNA objects passed, to help script authors to avoid bugs with accessing removed data.
Diffstat (limited to 'source/blender/makesrna/intern/rna_color.c')
-rw-r--r--source/blender/makesrna/intern/rna_color.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index c5f1ac748fa..c93d2ef15cf 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -329,12 +329,27 @@ static CBData *rna_ColorRampElement_new(struct ColorBand *coba, ReportList *repo
return element;
}
-static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, CBData *element)
+static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, PointerRNA *element_ptr)
{
+ CBData *element = element_ptr->data;
int index = (int)(element - coba->data);
- if (colorband_element_remove(coba, index) == 0)
+ if (colorband_element_remove(coba, index) == FALSE) {
BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element");
+ return;
+ }
+ RNA_POINTER_INVALIDATE(element_ptr);
+}
+
+void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr)
+{
+ CurveMapPoint *point = point_ptr->data;
+ if (curvemap_remove_point(cuma, point) == FALSE) {
+ BKE_report(reports, RPT_ERROR, "Unable to remove curve point");
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(point_ptr);
}
static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -559,10 +574,12 @@ static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "New point");
RNA_def_function_return(func, parm);
- func = RNA_def_function(srna, "remove", "curvemap_remove_point");
+ func = RNA_def_function(srna, "remove", "rna_CurveMap_remove_point");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Delete point from CurveMap");
parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "PointElement to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_curvemap(BlenderRNA *brna)
@@ -711,7 +728,8 @@ static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Delete element from ColorRamp");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
}
static void rna_def_color_ramp(BlenderRNA *brna)