From 052e40a9f88b4e19e4c8a3bbf74ee075d9fb9c54 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 24 Jan 2017 11:45:39 +0800 Subject: [PATCH] fix memory leaks of graphics node --- native/cocos/editor-support/creator/CCGraphicsNode.cpp | 7 ++++++- native/cocos/editor-support/creator/Triangulate.cpp | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.cpp b/native/cocos/editor-support/creator/CCGraphicsNode.cpp index 80a5e7d21e..9f6a094717 100644 --- a/native/cocos/editor-support/creator/CCGraphicsNode.cpp +++ b/native/cocos/editor-support/creator/CCGraphicsNode.cpp @@ -385,6 +385,11 @@ void GraphicsNode::clear(bool clean) CC_SAFE_DELETE(_verts); CC_SAFE_DELETE(_indices); + + for(auto&& it : _commands) { + delete it; + } + _commands.clear(); } _nPoints = 0; @@ -1276,4 +1281,4 @@ void GraphicsNode::onDraw(const Mat4 &transform, uint32_t flags) CHECK_GL_ERROR_DEBUG(); } -} \ No newline at end of file +} diff --git a/native/cocos/editor-support/creator/Triangulate.cpp b/native/cocos/editor-support/creator/Triangulate.cpp index 4b2bb123ac..43795cbe3b 100644 --- a/native/cocos/editor-support/creator/Triangulate.cpp +++ b/native/cocos/editor-support/creator/Triangulate.cpp @@ -101,6 +101,7 @@ bool Triangulate::process(const VecVertex *contour, int offset, int n, std::vect if (0 >= (count--)) { //** Triangulate: ERROR - probable bad polygon! + delete []V; return false; } @@ -136,4 +137,4 @@ bool Triangulate::process(const VecVertex *contour, int offset, int n, std::vect delete []V; return true; -} \ No newline at end of file +}