Forráskód Böngészése

Merge pull request #2 from damucz/master

memory leaks
Nathan Sweet 12 éve
szülő
commit
0833be847e

+ 1 - 0
spine-cpp/includes/spine/Animation.h

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

+ 1 - 0
spine-cpp/includes/spine/BaseAtlas.h

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

+ 1 - 0
spine-cpp/includes/spine/Skin.h

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

+ 8 - 0
spine-cpp/src/spine/Animation.cpp

@@ -18,6 +18,14 @@ Animation::Animation (const vector<Timeline*> &timelines, float 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) {
 	if (!skeleton) throw std::invalid_argument("skeleton cannot be null.");
 

+ 2 - 0
spine-cpp/src/spine/BaseSkeletonJson.cpp

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

+ 7 - 0
spine-cpp/src/spine/Skin.cpp

@@ -8,6 +8,13 @@ Skin::Skin (const std::string &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) {
 	Key key = {slotIndex, name};
 	attachments[key] = attachment;