Revision: 28618
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28618
Author:   campbellbarton
Date:     2010-05-06 16:53:27 +0200 (Thu, 06 May 2010)

Log Message:
-----------
more checks to last commit
- dont allow new() to return an existing fcurve.
- dont allow creating fcurves with blank paths.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_action.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_action.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_action.c   2010-05-06 
14:43:56 UTC (rev 28617)
+++ trunk/blender/source/blender/makesrna/intern/rna_action.c   2010-05-06 
14:53:27 UTC (rev 28618)
@@ -89,9 +89,20 @@
        MEM_freeN(agrp); 
 }
 
-static FCurve *rna_Action_fcurve_new(bAction *act, char *data_path, int index, 
char *group)
+static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, char 
*data_path, int index, char *group)
 {
        if(group && group[0]=='\0') group= NULL;
+
+       if(data_path[0] == '\0') {
+               BKE_report(reports, RPT_ERROR, "FCurve data path empty, invalid 
argument");
+               return NULL;
+       }
+
+       /* annoying, check if this exists */
+       if(verify_fcurve(act, group, data_path, index, 0)) {
+               BKE_reportf(reports, RPT_ERROR, "FCurve '%s[%d]' alredy exists 
in action '%s'", data_path, index, act->id.name+2);
+               return NULL;
+       }
        return verify_fcurve(act, group, data_path, index, 1);
 }
 
@@ -352,9 +363,10 @@
 
        func= RNA_def_function(srna, "new", "rna_Action_fcurve_new");
        RNA_def_function_ui_description(func, "Add a keyframe to the curve.");
-       parm= RNA_def_string(func, "data_path", "Data Path", 0, "", "FCurve 
data path to use.");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       parm= RNA_def_string(func, "data_path", "", 0, "Data Path", "FCurve 
data path to use.");
        parm= RNA_def_int(func, "array_index", 0, 0, INT_MAX, "Index", "Array 
index.", 0, INT_MAX);
-       parm= RNA_def_string(func, "action_group", "Action Group", 0, "", 
"Acton group to add this fcurve into.");
+       parm= RNA_def_string(func, "action_group", "", 0, "Action Group", 
"Acton group to add this fcurve into.");
 
        parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "Newly created 
fcurve");
        RNA_def_function_return(func, parm);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to