memory leaks

This commit is contained in:
damucz 2013-02-23 23:18:37 +01:00
parent 31b07f8625
commit 325d3265b9
6 changed files with 20 additions and 0 deletions

View File

@ -15,6 +15,7 @@ public:
float duration; float duration;
Animation (const std::vector<Timeline*> &timelines, float duration); Animation (const std::vector<Timeline*> &timelines, float duration);
~Animation();
void apply (BaseSkeleton *skeleton, float time, bool loop); void apply (BaseSkeleton *skeleton, float time, bool loop);
}; };

View File

@ -71,6 +71,7 @@ public:
int *splits; int *splits;
int *pads; int *pads;
BaseAtlasRegion() : splits(0), pads(0) {}
virtual ~BaseAtlasRegion (); virtual ~BaseAtlasRegion ();
}; };

View File

@ -31,6 +31,7 @@ public:
std::string name; std::string name;
Skin (const std::string &name); Skin (const std::string &name);
~Skin();
void addAttachment (int slotIndex, const std::string &name, Attachment *attachment); void addAttachment (int slotIndex, const std::string &name, Attachment *attachment);

View File

@ -18,6 +18,14 @@ Animation::Animation (const vector<Timeline*> &timelines, float duration) :
duration(duration) { duration(duration) {
} }
Animation::~Animation()
{
for (std::vector<Timeline*>::iterator iter = timelines.begin(); iter != timelines.end(); ++iter)
{
delete *iter;
}
}
void Animation::apply (BaseSkeleton *skeleton, float time, bool loop) { void Animation::apply (BaseSkeleton *skeleton, float time, bool loop) {
if (!skeleton) throw std::invalid_argument("skeleton cannot be null."); if (!skeleton) throw std::invalid_argument("skeleton cannot be null.");

View File

@ -35,6 +35,8 @@ BaseSkeletonJson::BaseSkeletonJson (BaseAttachmentLoader *attachmentLoader) :
} }
BaseSkeletonJson::~BaseSkeletonJson () { BaseSkeletonJson::~BaseSkeletonJson () {
if (attachmentLoader)
delete attachmentLoader;
} }
SkeletonData* BaseSkeletonJson::readSkeletonData (std::ifstream &file) const { SkeletonData* BaseSkeletonJson::readSkeletonData (std::ifstream &file) const {

View File

@ -8,6 +8,13 @@ Skin::Skin (const std::string &name) :
name(name) { name(name) {
} }
Skin::~Skin()
{
for (std::map<Key, Attachment*>::iterator iter = attachments.begin(); iter != attachments.end(); ++iter) {
delete iter->second;
}
}
void Skin::addAttachment (int slotIndex, const std::string &name, Attachment *attachment) { void Skin::addAttachment (int slotIndex, const std::string &name, Attachment *attachment) {
Key key = {slotIndex, name}; Key key = {slotIndex, name};
attachments[key] = attachment; attachments[key] = attachment;