[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18644] branches/blender2.5/blender/source /blender/blenkernel/intern/fcurve.c: Animato - FCurve Modifier Bugfixes
Joshua Leung
aligorith at gmail.com
Sat Jan 24 09:22:05 CET 2009
Revision: 18644
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18644
Author: aligorith
Date: 2009-01-24 09:21:39 +0100 (Sat, 24 Jan 2009)
Log Message:
-----------
Animato - FCurve Modifier Bugfixes
* FModifier data is now allocated correctly, solving crashes on loading files containing IPO-curves with cyclic extrapolation
* Fixed memory leaks with FModifiers and their data not being freed correctly. Not sure exactly why the old code didn't work for this.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c 2009-01-24 06:08:46 UTC (rev 18643)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c 2009-01-24 08:21:39 UTC (rev 18644)
@@ -1412,10 +1412,13 @@
return NULL;
}
- /* add modifier data */
+ /* add modifier itself */
fcm= MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
BLI_addtail(&fcu->modifiers, fcm);
+ /* add modifier's data */
+ fcm->data= MEM_callocN(fmi->size, "F-Curve Modifier Data");
+
/* init custom settings if necessary */
if (fmi->new_data)
fmi->new_data(fcm->data);
@@ -1452,16 +1455,25 @@
{
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
- /* sanity checks */
- if ELEM3(NULL, fcu, fcm, fmi)
+ /* sanity check */
+ if (fcm == NULL)
return;
+
+ /* free modifier's special data (stored inside fcm->data) */
+ if (fmi && fmi->free_data)
+ fmi->free_data(fcm);
- /* free modifier's special data */
- if (fmi->free_data)
- fmi->free_data(fcm);
+ /* free modifier's data (fcm->data) */
+ MEM_freeN(fcm->data);
/* remove modifier from stack */
- BLI_freelinkN(&fcu->modifiers, fcm);
+ if (fcu)
+ BLI_freelinkN(&fcu->modifiers, fcm);
+ else {
+ // XXX this case can probably be removed some day, as it shouldn't happen...
+ printf("fcurve_remove_modifier() - no fcurve \n");
+ MEM_freeN(fcm);
+ }
}
/* Remove all of a given F-Curve's modifiers */
More information about the Bf-blender-cvs
mailing list