fix for memory leak grabbing masks and grease pencil in the dope sheet. (also NULL after freeing)

This commit is contained in:
Campbell Barton 2012-09-24 01:50:26 +00:00
parent e6e5e92869
commit 953e2321dd
2 changed files with 8 additions and 1 deletions

@ -3292,15 +3292,19 @@ static void createTransActionData(bContext *C, TransInfo *t)
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
if (t->mode == TFM_TIME_SLIDE) {
t->customData = MEM_callocN((sizeof(float) * 2) + (sizeof(tGPFtransdata) * count), "TimeSlide + tGPFtransdata");
t->flag |= T_FREE_CUSTOMDATA;
tfd = (tGPFtransdata *)((float *)(t->customData) + 2);
}
else {
t->customData = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata");
t->flag |= T_FREE_CUSTOMDATA;
tfd = (tGPFtransdata *)(t->customData);
}
}
else if (t->mode == TFM_TIME_SLIDE)
else if (t->mode == TFM_TIME_SLIDE) {
t->customData = MEM_callocN(sizeof(float) * 2, "TimeSlide Min/Max");
t->flag |= T_FREE_CUSTOMDATA;
}
/* loop 2: build transdata array */
for (ale = anim_data.first; ale; ale = ale->next) {
@ -5762,6 +5766,7 @@ static void transDataTrackingFree(TransInfo *t)
MEM_freeN(tdt->smarkers);
MEM_freeN(tdt);
t->customData = NULL;
}
}

@ -1293,9 +1293,11 @@ void postTrans(bContext *C, TransInfo *t)
if (t->customFree) {
/* Can take over freeing t->data and data2d etc... */
t->customFree(t);
BLI_assert(t->customData == NULL);
}
else if ((t->customData != NULL) && (t->flag & T_FREE_CUSTOMDATA)) {
MEM_freeN(t->customData);
t->customData = NULL;
}
/* postTrans can be called when nothing is selected, so data is NULL already */