[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51815] trunk/blender/source/blender: all remove functions now invalidate the RNA objects passed, to help script authors to avoid bugs with accessing removed data.
Campbell Barton
ideasman42 at gmail.com
Fri Nov 2 10:41:31 CET 2012
Revision: 51815
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51815
Author: campbellbarton
Date: 2012-11-02 09:41:26 +0000 (Fri, 02 Nov 2012)
Log Message:
-----------
all remove functions now invalidate the RNA objects passed, to help script authors to avoid bugs with accessing removed data.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_colortools.h
trunk/blender/source/blender/blenkernel/BKE_tracking.h
trunk/blender/source/blender/blenkernel/intern/colortools.c
trunk/blender/source/blender/blenkernel/intern/tracking.c
trunk/blender/source/blender/collada/DocumentExporter.cpp
trunk/blender/source/blender/collada/collada_internal.h
trunk/blender/source/blender/editors/object/object_vgroup.c
trunk/blender/source/blender/makesrna/intern/rna_action.c
trunk/blender/source/blender/makesrna/intern/rna_animation.c
trunk/blender/source/blender/makesrna/intern/rna_armature.c
trunk/blender/source/blender/makesrna/intern/rna_color.c
trunk/blender/source/blender/makesrna/intern/rna_curve.c
trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
trunk/blender/source/blender/makesrna/intern/rna_main_api.c
trunk/blender/source/blender/makesrna/intern/rna_mask.c
trunk/blender/source/blender/makesrna/intern/rna_mesh.c
trunk/blender/source/blender/makesrna/intern/rna_meta.c
trunk/blender/source/blender/makesrna/intern/rna_nla.c
trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
trunk/blender/source/blender/makesrna/intern/rna_object.c
trunk/blender/source/blender/makesrna/intern/rna_pose.c
trunk/blender/source/blender/makesrna/intern/rna_scene.c
trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c
trunk/blender/source/blender/makesrna/intern/rna_space.c
trunk/blender/source/blender/makesrna/intern/rna_tracking.c
trunk/blender/source/blender/makesrna/intern/rna_userdef.c
trunk/blender/source/blender/makesrna/intern/rna_wm_api.c
trunk/blender/source/blender/windowmanager/WM_keymap.h
trunk/blender/source/blender/windowmanager/intern/wm_keymap.c
Modified: trunk/blender/source/blender/blenkernel/BKE_colortools.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_colortools.h 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/blenkernel/BKE_colortools.h 2012-11-02 09:41:26 UTC (rev 51815)
@@ -63,8 +63,8 @@
#define CURVEMAP_SLOPE_POSITIVE 1
void curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope);
void curvemap_remove(struct CurveMap *cuma, const short flag);
-void curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
-struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y);
+int curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
+struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y);
void curvemap_sethandle(struct CurveMap *cuma, int type);
void curvemapping_changed(struct CurveMapping *cumap, int rem_doubles);
Modified: trunk/blender/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_tracking.h 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/blenkernel/BKE_tracking.h 2012-11-02 09:41:26 UTC (rev 51815)
@@ -114,7 +114,7 @@
/* **** Object **** */
struct MovieTrackingObject *BKE_tracking_object_add(struct MovieTracking *tracking, const char *name);
-void BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object);
+int BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object);
void BKE_tracking_object_unique_name(struct MovieTracking *tracking, struct MovieTrackingObject *object);
Modified: trunk/blender/source/blender/blenkernel/intern/colortools.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/colortools.c 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/blenkernel/intern/colortools.c 2012-11-02 09:41:26 UTC (rev 51815)
@@ -182,14 +182,14 @@
/* ********** NOTE: requires curvemapping_changed() call after ******** */
/* remove specified point */
-void curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
+int curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
{
CurveMapPoint *cmp;
int a, b, removed = 0;
/* must have 2 points minimum */
if (cuma->totpoint <= 2)
- return;
+ return FALSE;
cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points");
@@ -205,6 +205,7 @@
MEM_freeN(cuma->curve);
cuma->curve = cmp;
cuma->totpoint -= removed;
+ return (removed != 0);
}
/* removes with flag set */
Modified: trunk/blender/source/blender/blenkernel/intern/tracking.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/tracking.c 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/blenkernel/intern/tracking.c 2012-11-02 09:41:26 UTC (rev 51815)
@@ -1189,17 +1189,17 @@
return object;
}
-void BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *object)
+int BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *object)
{
MovieTrackingTrack *track;
int index = BLI_findindex(&tracking->objects, object);
- if (index < 0)
- return;
+ if (index == -1)
+ return FALSE;
if (object->flag & TRACKING_OBJECT_CAMERA) {
/* object used for camera solving can't be deleted */
- return;
+ return FALSE;
}
track = object->tracks.first;
@@ -1215,10 +1215,11 @@
tracking->tot_object--;
- if (index > 0)
+ if (index != 0)
tracking->objectnr = index - 1;
else
tracking->objectnr = 0;
+ return TRUE;
}
void BKE_tracking_object_unique_name(MovieTracking *tracking, MovieTrackingObject *object)
Modified: trunk/blender/source/blender/collada/DocumentExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentExporter.cpp 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/collada/DocumentExporter.cpp 2012-11-02 09:41:26 UTC (rev 51815)
@@ -110,6 +110,7 @@
}
#include "collada_internal.h"
+#include "collada_utils.h"
#include "DocumentExporter.h"
extern bool bc_has_object_type(LinkNode *export_set, short obtype);
Modified: trunk/blender/source/blender/collada/collada_internal.h
===================================================================
--- trunk/blender/source/blender/collada/collada_internal.h 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/collada/collada_internal.h 2012-11-02 09:41:26 UTC (rev 51815)
@@ -88,6 +88,7 @@
extern std::string id_name(void *id);
+extern std::string get_geometry_id(Object *ob);
extern std::string get_geometry_id(Object *ob, bool use_instantiation);
extern std::string get_light_id(Object *ob);
Modified: trunk/blender/source/blender/editors/object/object_vgroup.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_vgroup.c 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/editors/object/object_vgroup.c 2012-11-02 09:41:26 UTC (rev 51815)
@@ -138,21 +138,12 @@
void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup)
{
- bDeformGroup *dg = (bDeformGroup *)ob->defbase.first;
+ BLI_assert(BLI_findindex(&ob->defbase, defgroup) != -1);
- while (dg) {
- if (dg == defgroup)
- break;
- dg = dg->next;
- }
-
- if (dg == NULL)
- return;
-
if (ED_vgroup_object_is_edit_mode(ob))
- vgroup_delete_edit_mode(ob, dg);
+ vgroup_delete_edit_mode(ob, defgroup);
else
- vgroup_delete_object_mode(ob, dg);
+ vgroup_delete_object_mode(ob, defgroup);
}
void ED_vgroup_clear(Object *ob)
Modified: trunk/blender/source/blender/makesrna/intern/rna_action.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_action.c 2012-11-01 17:52:21 UTC (rev 51814)
+++ trunk/blender/source/blender/makesrna/intern/rna_action.c 2012-11-02 09:41:26 UTC (rev 51815)
@@ -27,6 +27,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -68,12 +69,13 @@
return action_groups_add_new(act, name);
}
-static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionGroup *agrp)
+static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerRNA *agrp_ptr)
{
+ bActionGroup *agrp = agrp_ptr->data;
FCurve *fcu, *fcn;
/* try to remove the F-Curve from the action */
- if (!BLI_remlink_safe(&act->groups, agrp)) {
+ if (BLI_remlink_safe(&act->groups, agrp) == FALSE) {
BKE_reportf(reports, RPT_ERROR, "Action group '%s' not found in action '%s'", agrp->name, act->id.name + 2);
return;
}
@@ -81,16 +83,16 @@
/* move every one one of the group's F-Curves out into the Action again */
for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcn) {
fcn = fcu->next;
-
+
/* remove from group */
action_groups_remove_channel(act, fcu);
-
+
/* tack onto the end */
BLI_addtail(&act->curves, fcu);
}
-
- /* XXX, invalidates PyObject */
+
MEM_freeN(agrp);
+ RNA_POINTER_INVALIDATE(agrp_ptr);
}
static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const char *data_path,
@@ -112,8 +114,9 @@
return verify_fcurve(act, group, NULL, data_path, index, 1);
}
-static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *fcu)
+static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerRNA *fcu_ptr)
{
+ FCurve *fcu = fcu_ptr->data;
if (fcu->grp) {
if (BLI_findindex(&act->groups, fcu->grp) == -1) {
BKE_reportf(reports, RPT_ERROR, "F-Curve's action group '%s' not found in action '%s'",
@@ -123,6 +126,7 @@
action_groups_remove_channel(act, fcu);
free_fcurve(fcu);
+ RNA_POINTER_INVALIDATE(fcu_ptr);
}
else {
if (BLI_findindex(&act->curves, fcu) == -1) {
@@ -132,6 +136,7 @@
BLI_remlink(&act->curves, fcu);
free_fcurve(fcu);
+ RNA_POINTER_INVALIDATE(fcu_ptr);
}
}
@@ -145,15 +150,16 @@
return marker;
}
-static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, TimeMarker *marker)
+static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, PointerRNA *marker_ptr)
{
- if (!BLI_remlink_safe(&act->markers, marker)) {
+ TimeMarker *marker = marker_ptr->data;
+ if (BLI_remlink_safe(&act->markers, marker) == FALSE) {
BKE_reportf(reports, RPT_ERROR, "Timeline marker '%s' not found in action '%s'", marker->name, act->id.name + 2);
return;
}
- /* XXX, invalidates PyObject */
MEM_freeN(marker);
+ RNA_POINTER_INVALIDATE(marker_ptr);
}
static PointerRNA rna_Action_active_pose_marker_get(PointerRNA *ptr)
@@ -516,7 +522,8 @@
RNA_def_function_ui_description(func, "Remove action group");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "action_group", "ActionGroup", "", "Action group 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_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
@@ -547,7 +554,8 @@
RNA_def_function_ui_description(func, "Remove action group");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve 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_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
@@ -575,7 +583,8 @@
RNA_def_function_ui_description(func, "Remove a timeline marker");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker 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);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list