Merge branch 'v3' of github.com:cocos2d/cocos2d-x into v3

This commit is contained in:
pandamicro 2015-12-20 22:45:51 +08:00
commit 1071f63ac7
115 changed files with 559 additions and 413 deletions

View File

@ -5,6 +5,7 @@ cocos2d-x-3.10 December ? 2015
[NEW] UI: UIText::clone supports clone the text effect. [NEW] UI: UIText::clone supports clone the text effect.
[NEW] Label: Add methods to query label effect state. [NEW] Label: Add methods to query label effect state.
[REFINE] UI: Slider `setCapInsetProgressBarRebderer` change to `setCapInsetProgressBarRenderer`.
[REFINE] UI: RichText support new line element. [REFINE] UI: RichText support new line element.
[REFINE] UI: Set focus to Widget when touched. [REFINE] UI: Set focus to Widget when touched.
[REFINE] UI: Change PageView to derived from ListView. [REFINE] UI: Change PageView to derived from ListView.
@ -14,6 +15,7 @@ cocos2d-x-3.10 December ? 2015
[REFINE] Mac: Make engine compatible for 32bit Mac. [REFINE] Mac: Make engine compatible for 32bit Mac.
[REFINE] Audio: AudioEngine on Linux replace the original SimpleAudioEngine with a new version of FMOD, now AudioEngine support all platforms! [REFINE] Audio: AudioEngine on Linux replace the original SimpleAudioEngine with a new version of FMOD, now AudioEngine support all platforms!
[FIX] Network: fix possible websocket crash in its destructor.
[FIX] Core: Fix premultiplyAlpha for mipmaps and compressed textures. [FIX] Core: Fix premultiplyAlpha for mipmaps and compressed textures.
[FIX] UI: Fix Scale9sprite rendering error when content size smaller than the sum of leftInset and rightInset. [FIX] UI: Fix Scale9sprite rendering error when content size smaller than the sum of leftInset and rightInset.
[FIX] Win32: Fix EditBox crash when removing an EditBox in a scheduler. [FIX] Win32: Fix EditBox crash when removing an EditBox in a scheduler.

View File

@ -63,7 +63,7 @@ PointArray* PointArray::create(ssize_t capacity)
bool PointArray::initWithCapacity(ssize_t capacity) bool PointArray::initWithCapacity(ssize_t capacity)
{ {
_controlPoints = new vector<Vec2*>(); _controlPoints = new (std::nothrow) vector<Vec2*>();
return true; return true;
} }
@ -158,7 +158,7 @@ ssize_t PointArray::count() const
PointArray* PointArray::reverse() const PointArray* PointArray::reverse() const
{ {
vector<Vec2*> *newArray = new vector<Vec2*>(); vector<Vec2*> *newArray = new (std::nothrow) vector<Vec2*>();
vector<Vec2*>::reverse_iterator iter; vector<Vec2*>::reverse_iterator iter;
Vec2 *point = nullptr; Vec2 *point = nullptr;
for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter) for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter)

View File

@ -494,7 +494,7 @@ CallFuncN * CallFuncN::clone() const
__CCCallFuncND * __CCCallFuncND::create(Ref* selectorTarget, SEL_CallFuncND selector, void* d) __CCCallFuncND * __CCCallFuncND::create(Ref* selectorTarget, SEL_CallFuncND selector, void* d)
{ {
__CCCallFuncND* ret = new __CCCallFuncND(); __CCCallFuncND* ret = new (std::nothrow) __CCCallFuncND();
if (ret && ret->initWithTarget(selectorTarget, selector, d)) { if (ret && ret->initWithTarget(selectorTarget, selector, d)) {
ret->autorelease(); ret->autorelease();
@ -528,7 +528,7 @@ void __CCCallFuncND::execute()
__CCCallFuncND * __CCCallFuncND::clone() const __CCCallFuncND * __CCCallFuncND::clone() const
{ {
// no copy constructor // no copy constructor
auto a = new __CCCallFuncND(); auto a = new (std::nothrow) __CCCallFuncND();
if( _selectorTarget) if( _selectorTarget)
{ {
@ -561,7 +561,7 @@ void __CCCallFuncO::execute()
__CCCallFuncO * __CCCallFuncO::create(Ref* selectorTarget, SEL_CallFuncO selector, Ref* object) __CCCallFuncO * __CCCallFuncO::create(Ref* selectorTarget, SEL_CallFuncO selector, Ref* object)
{ {
__CCCallFuncO *ret = new __CCCallFuncO(); __CCCallFuncO *ret = new (std::nothrow) __CCCallFuncO();
if (ret && ret->initWithTarget(selectorTarget, selector, object)) { if (ret && ret->initWithTarget(selectorTarget, selector, object)) {
ret->autorelease(); ret->autorelease();
@ -589,7 +589,7 @@ bool __CCCallFuncO::initWithTarget(Ref* selectorTarget, SEL_CallFuncO selector,
__CCCallFuncO * __CCCallFuncO::clone() const __CCCallFuncO * __CCCallFuncO::clone() const
{ {
// no copy constructor // no copy constructor
auto a = new __CCCallFuncO(); auto a = new (std::nothrow) __CCCallFuncO();
if( _selectorTarget) if( _selectorTarget)
{ {

View File

@ -46,8 +46,8 @@ rect()
filename = other.filename; filename = other.filename;
isVertsOwner = true; isVertsOwner = true;
rect = other.rect; rect = other.rect;
triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount]; triangles.verts = new (std::nothrow) V3F_C4B_T2F[other.triangles.vertCount];
triangles.indices = new unsigned short[other.triangles.indexCount]; triangles.indices = new (std::nothrow) unsigned short[other.triangles.indexCount];
triangles.vertCount = other.triangles.vertCount; triangles.vertCount = other.triangles.vertCount;
triangles.indexCount = other.triangles.indexCount; triangles.indexCount = other.triangles.indexCount;
memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F)); memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F));
@ -62,8 +62,8 @@ PolygonInfo& PolygonInfo::operator= (const PolygonInfo& other)
filename = other.filename; filename = other.filename;
isVertsOwner = true; isVertsOwner = true;
rect = other.rect; rect = other.rect;
triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount]; triangles.verts = new (std::nothrow) V3F_C4B_T2F[other.triangles.vertCount];
triangles.indices = new unsigned short[other.triangles.indexCount]; triangles.indices = new (std::nothrow) unsigned short[other.triangles.indexCount];
triangles.vertCount = other.triangles.vertCount; triangles.vertCount = other.triangles.vertCount;
triangles.indexCount = other.triangles.indexCount; triangles.indexCount = other.triangles.indexCount;
memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F)); memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F));
@ -148,7 +148,7 @@ AutoPolygon::AutoPolygon(const std::string &filename)
,_scaleFactor(0) ,_scaleFactor(0)
{ {
_filename = filename; _filename = filename;
_image = new Image(); _image = new (std::nothrow) Image();
_image->initWithImageFile(filename); _image->initWithImageFile(filename);
CCASSERT(_image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888, "unsupported format, currently only supports rgba8888"); CCASSERT(_image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888, "unsupported format, currently only supports rgba8888");
_data = _image->getData(); _data = _image->getData();
@ -550,15 +550,15 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
std::vector<p2t::Point*> p2points; std::vector<p2t::Point*> p2points;
for(std::vector<Vec2>::const_iterator it = points.begin(); it<points.end(); it++) for(std::vector<Vec2>::const_iterator it = points.begin(); it<points.end(); it++)
{ {
p2t::Point * p = new p2t::Point(it->x, it->y); p2t::Point * p = new (std::nothrow) p2t::Point(it->x, it->y);
p2points.push_back(p); p2points.push_back(p);
} }
p2t::CDT cdt(p2points); p2t::CDT cdt(p2points);
cdt.Triangulate(); cdt.Triangulate();
std::vector<p2t::Triangle*> tris = cdt.GetTriangles(); std::vector<p2t::Triangle*> tris = cdt.GetTriangles();
V3F_C4B_T2F* verts= new V3F_C4B_T2F[points.size()]; V3F_C4B_T2F* verts= new (std::nothrow) V3F_C4B_T2F[points.size()];
unsigned short* indices = new unsigned short[tris.size()*3]; unsigned short* indices = new (std::nothrow) unsigned short[tris.size()*3];
unsigned short idx = 0; unsigned short idx = 0;
unsigned short vdx = 0; unsigned short vdx = 0;

View File

@ -9,7 +9,7 @@ NS_CC_BEGIN
ClippingRectangleNode* ClippingRectangleNode::create(const Rect& clippingRegion) ClippingRectangleNode* ClippingRectangleNode::create(const Rect& clippingRegion)
{ {
ClippingRectangleNode* node = new ClippingRectangleNode(); ClippingRectangleNode* node = new (std::nothrow) ClippingRectangleNode();
if (node && node->init()) { if (node && node->init()) {
node->setClippingRegion(clippingRegion); node->setClippingRegion(clippingRegion);
node->autorelease(); node->autorelease();
@ -22,7 +22,7 @@ ClippingRectangleNode* ClippingRectangleNode::create(const Rect& clippingRegion)
ClippingRectangleNode* ClippingRectangleNode::create() ClippingRectangleNode* ClippingRectangleNode::create()
{ {
ClippingRectangleNode* node = new ClippingRectangleNode(); ClippingRectangleNode* node = new (std::nothrow) ClippingRectangleNode();
if (node && node->init()) { if (node && node->init()) {
node->autorelease(); node->autorelease();
} else { } else {

View File

@ -177,7 +177,8 @@ void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
if(iter.second->getCount() > 0) if(iter.second->getCount() > 0)
{ {
auto& cmd = _renderCommands[index++]; auto& cmd = _renderCommands[index++];
cmd.init(iter.first, _texture->getName(), getGLProgramState(), BlendFunc::ALPHA_NON_PREMULTIPLIED, iter.second, _modelViewTransform, flags); auto blendfunc = _texture->hasPremultipliedAlpha() ? BlendFunc::ALPHA_PREMULTIPLIED : BlendFunc::ALPHA_NON_PREMULTIPLIED;
cmd.init(iter.first, _texture->getName(), getGLProgramState(), blendfunc, iter.second, _modelViewTransform, flags);
renderer->addCommand(&cmd); renderer->addCommand(&cmd);
} }
} }

View File

@ -79,7 +79,7 @@ FontAtlas::FontAtlas(Font &theFont)
_currentPageDataSize *= 2; _currentPageDataSize *= 2;
} }
_currentPageData = new unsigned char[_currentPageDataSize]; _currentPageData = new (std::nothrow) unsigned char[_currentPageDataSize];
memset(_currentPageData, 0, _currentPageDataSize); memset(_currentPageData, 0, _currentPageDataSize);
auto pixelFormat = outlineSize > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8; auto pixelFormat = outlineSize > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
@ -110,7 +110,7 @@ FontAtlas::~FontAtlas()
#endif #endif
_font->release(); _font->release();
relaseTextures(); releaseTextures();
delete []_currentPageData; delete []_currentPageData;
@ -123,7 +123,7 @@ FontAtlas::~FontAtlas()
#endif #endif
} }
void FontAtlas::relaseTextures() void FontAtlas::releaseTextures()
{ {
for( auto &item: _atlasTextures) for( auto &item: _atlasTextures)
{ {
@ -132,6 +132,11 @@ void FontAtlas::relaseTextures()
_atlasTextures.clear(); _atlasTextures.clear();
} }
void FontAtlas::relaseTextures()
{
releaseTextures();
}
void FontAtlas::purgeTexturesAtlas() void FontAtlas::purgeTexturesAtlas()
{ {
if (_fontFreeType && _atlasTextures.size() > 1) if (_fontFreeType && _atlasTextures.size() > 1)

View File

@ -109,7 +109,10 @@ public:
void setAliasTexParameters(); void setAliasTexParameters();
protected: protected:
void relaseTextures(); void releaseTextures();
/** @deprecated Use method releaseTextures() instead */
CC_DEPRECATED_ATTRIBUTE void relaseTextures();
void findNewCharacters(const std::u16string& u16Text, std::unordered_map<unsigned short, unsigned short>& charCodeMap); void findNewCharacters(const std::u16string& u16Text, std::unordered_map<unsigned short, unsigned short>& charCodeMap);

View File

@ -290,7 +290,7 @@ std::set<unsigned int>* BMFontConfiguration::parseConfigFile(const std::string&
return nullptr; return nullptr;
} }
std::set<unsigned int> *validCharsString = new std::set<unsigned int>(); std::set<unsigned int> *validCharsString = new (std::nothrow) std::set<unsigned int>();
auto contentsLen = data.getSize(); auto contentsLen = data.getSize();
char line[512]; char line[512];
@ -364,7 +364,7 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
{ {
/* based on http://www.angelcode.com/products/bmfont/doc/file_format.html file format */ /* based on http://www.angelcode.com/products/bmfont/doc/file_format.html file format */
set<unsigned int> *validCharsString = new set<unsigned int>(); set<unsigned int> *validCharsString = new (std::nothrow) set<unsigned int>();
unsigned long remains = size; unsigned long remains = size;
@ -687,7 +687,7 @@ int * FontFNT::getHorizontalKerningForTextUTF16(const std::u16string& text, int
if (!outNumLetters) if (!outNumLetters)
return 0; return 0;
int *sizes = new int[outNumLetters]; int *sizes = new (std::nothrow) int[outNumLetters];
if (!sizes) if (!sizes)
return 0; return 0;
@ -821,7 +821,7 @@ void FontFNT::reloadBMFontResource(const std::string& fntFilePath)
if (ret) if (ret)
{ {
s_configurations->insert(fntFilePath, ret); s_configurations->insert(fntFilePath, ret);
TextureCache::getInstance()->reloadTexture(ret->getAtlasName()); Director::getInstance()->getTextureCache()->reloadTexture(ret->getAtlasName());
} }
} }

View File

@ -230,7 +230,7 @@ int * FontFreeType::getHorizontalKerningForTextUTF16(const std::u16string& text,
if (!outNumLetters) if (!outNumLetters)
return nullptr; return nullptr;
int *sizes = new int[outNumLetters]; int *sizes = new (std::nothrow) int[outNumLetters];
if (!sizes) if (!sizes)
return nullptr; return nullptr;
memset(sizes,0,outNumLetters * sizeof(int)); memset(sizes,0,outNumLetters * sizeof(int));
@ -309,7 +309,7 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
if (_outlineSize > 0) if (_outlineSize > 0)
{ {
auto copyBitmap = new unsigned char[outWidth * outHeight]; auto copyBitmap = new (std::nothrow) unsigned char[outWidth * outHeight];
memcpy(copyBitmap,ret,outWidth * outHeight * sizeof(unsigned char)); memcpy(copyBitmap,ret,outWidth * outHeight * sizeof(unsigned char));
FT_BBox bbox; FT_BBox bbox;
@ -342,7 +342,7 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
outRect.origin.y = -blendImageMaxY + _outlineSize; outRect.origin.y = -blendImageMaxY + _outlineSize;
long index, index2; long index, index2;
auto blendImage = new unsigned char[blendWidth * blendHeight * 2]; auto blendImage = new (std::nothrow) unsigned char[blendWidth * blendHeight * 2];
memset(blendImage, 0, blendWidth * blendHeight * 2); memset(blendImage, 0, blendWidth * blendHeight * 2);
auto px = outlineMinX - blendImageMinX; auto px = outlineMinX - blendImageMinX;
@ -415,7 +415,7 @@ unsigned char * FontFreeType::getGlyphBitmapWithOutline(unsigned short theChar,
long rows = (bbox.yMax - bbox.yMin)>>6; long rows = (bbox.yMax - bbox.yMin)>>6;
FT_Bitmap bmp; FT_Bitmap bmp;
bmp.buffer = new unsigned char[width * rows]; bmp.buffer = new (std::nothrow) unsigned char[width * rows];
memset(bmp.buffer, 0, width * rows); memset(bmp.buffer, 0, width * rows);
bmp.width = (int)width; bmp.width = (int)width;
bmp.rows = (int)rows; bmp.rows = (int)rows;

View File

@ -52,6 +52,7 @@ public:
LabelLetter() LabelLetter()
{ {
_textureAtlas = nullptr; _textureAtlas = nullptr;
_letterVisible = true;
} }
static LabelLetter* createWithTexture(Texture2D *texture, const Rect& rect, bool rotated = false) static LabelLetter* createWithTexture(Texture2D *texture, const Rect& rect, bool rotated = false)
@ -59,7 +60,7 @@ public:
auto letter = new (std::nothrow) LabelLetter(); auto letter = new (std::nothrow) LabelLetter();
if (letter && letter->initWithTexture(texture, rect, rotated)) if (letter && letter->initWithTexture(texture, rect, rotated))
{ {
letter->setVisible(false); letter->Sprite::setVisible(false);
letter->autorelease(); letter->autorelease();
return letter; return letter;
} }
@ -130,13 +131,18 @@ public:
return; return;
} }
Color4B color4(_displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity); auto displayedOpacity = _displayedOpacity;
if(!_letterVisible)
{
displayedOpacity = 0.0f;
}
Color4B color4(_displayedColor.r, _displayedColor.g, _displayedColor.b, displayedOpacity);
// special opacity for premultiplied textures // special opacity for premultiplied textures
if (_opacityModifyRGB) if (_opacityModifyRGB)
{ {
color4.r *= _displayedOpacity / 255.0f; color4.r *= displayedOpacity / 255.0f;
color4.g *= _displayedOpacity / 255.0f; color4.g *= displayedOpacity / 255.0f;
color4.b *= _displayedOpacity / 255.0f; color4.b *= displayedOpacity / 255.0f;
} }
_quad.bl.colors = color4; _quad.bl.colors = color4;
_quad.br.colors = color4; _quad.br.colors = color4;
@ -146,10 +152,19 @@ public:
_textureAtlas->updateQuad(&_quad, _atlasIndex); _textureAtlas->updateQuad(&_quad, _atlasIndex);
} }
void setVisible(bool visible) override
{
_letterVisible = visible;
updateColor();
}
//LabelLetter doesn't need to draw directly. //LabelLetter doesn't need to draw directly.
void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override
{ {
} }
private:
bool _letterVisible;
}; };
Label* Label::create() Label* Label::create()

View File

@ -54,17 +54,14 @@ ProgressTimer::ProgressTimer()
ProgressTimer* ProgressTimer::create(Sprite* sp) ProgressTimer* ProgressTimer::create(Sprite* sp)
{ {
ProgressTimer *progressTimer = new (std::nothrow) ProgressTimer(); ProgressTimer *progressTimer = new (std::nothrow) ProgressTimer();
if (progressTimer->initWithSprite(sp)) if (progressTimer && progressTimer->initWithSprite(sp))
{ {
progressTimer->autorelease(); progressTimer->autorelease();
} return progressTimer;
else
{
delete progressTimer;
progressTimer = nullptr;
} }
return progressTimer; delete progressTimer;
return nullptr;
} }
bool ProgressTimer::initWithSprite(Sprite* sp) bool ProgressTimer::initWithSprite(Sprite* sp)

View File

@ -142,9 +142,11 @@ Sprite* Sprite::create()
return nullptr; return nullptr;
} }
bool Sprite::init(void) bool Sprite::init()
{ {
return initWithTexture(nullptr, Rect::ZERO ); initWithTexture(nullptr, Rect::ZERO);
return true;
} }
bool Sprite::initWithTexture(Texture2D *texture) bool Sprite::initWithTexture(Texture2D *texture)
@ -152,9 +154,11 @@ bool Sprite::initWithTexture(Texture2D *texture)
CCASSERT(texture != nullptr, "Invalid texture for sprite"); CCASSERT(texture != nullptr, "Invalid texture for sprite");
Rect rect = Rect::ZERO; Rect rect = Rect::ZERO;
rect.size = texture->getContentSize(); if (texture) {
rect.size = texture->getContentSize();
}
return initWithTexture(texture, rect); return initWithTexture(texture, rect, false);
} }
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect) bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect)
@ -173,7 +177,7 @@ bool Sprite::initWithFile(const std::string& filename)
_fileName = filename; _fileName = filename;
_fileType = 0; _fileType = 0;
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); Texture2D *texture = _director->getTextureCache()->addImage(filename);
if (texture) if (texture)
{ {
Rect rect = Rect::ZERO; Rect rect = Rect::ZERO;
@ -189,12 +193,16 @@ bool Sprite::initWithFile(const std::string& filename)
bool Sprite::initWithFile(const std::string &filename, const Rect& rect) bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
{ {
CCASSERT(filename.size()>0, "Invalid filename"); CCASSERT(!filename.empty(), "Invalid filename");
if (filename.empty())
{
return false;
}
_fileName = filename; _fileName = filename;
_fileType = 0; _fileType = 0;
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); Texture2D *texture = _director->getTextureCache()->addImage(filename);
if (texture) if (texture)
{ {
return initWithTexture(texture, rect); return initWithTexture(texture, rect);
@ -208,7 +216,11 @@ bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName) bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
{ {
CCASSERT(spriteFrameName.size() > 0, "Invalid spriteFrameName"); CCASSERT(!spriteFrameName.empty(), "Invalid spriteFrameName");
if (spriteFrameName.empty())
{
return false;
}
_fileName = spriteFrameName; _fileName = spriteFrameName;
_fileType = 1; _fileType = 1;
@ -220,6 +232,10 @@ bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame) bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
{ {
CCASSERT(spriteFrame != nullptr, "spriteFrame can't be nullptr!"); CCASSERT(spriteFrame != nullptr, "spriteFrame can't be nullptr!");
if (spriteFrame == nullptr)
{
return false;
}
bool bRet = initWithTexture(spriteFrame->getTexture(), spriteFrame->getRect()); bool bRet = initWithTexture(spriteFrame->getTexture(), spriteFrame->getRect());
setSpriteFrame(spriteFrame); setSpriteFrame(spriteFrame);
@ -229,21 +245,23 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
bool Sprite::initWithPolygon(const cocos2d::PolygonInfo &info) bool Sprite::initWithPolygon(const cocos2d::PolygonInfo &info)
{ {
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(info.filename); bool ret = false;
bool res = false;
if(initWithTexture(texture)) Texture2D *texture = _director->getTextureCache()->addImage(info.filename);
if(texture && initWithTexture(texture))
{ {
_polyInfo = info; _polyInfo = info;
setContentSize(_polyInfo.rect.size/Director::getInstance()->getContentScaleFactor()); setContentSize(_polyInfo.rect.size / _director->getContentScaleFactor());
res = true; ret = true;
} }
return res;
return ret;
} }
// designated initializer // designated initializer
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
{ {
bool result; bool result = false;
if (Node::init()) if (Node::init())
{ {
_batchNode = nullptr; _batchNode = nullptr;
@ -284,12 +302,10 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
setBatchNode(nullptr); setBatchNode(nullptr);
result = true; result = true;
} }
else
{
result = false;
}
_recursiveDirty = true; _recursiveDirty = true;
setDirty(true); setDirty(true);
return result; return result;
} }
@ -359,7 +375,7 @@ void Sprite::setTexture(Texture2D *texture)
if (texture == nullptr) if (texture == nullptr)
{ {
// Gets the texture by key firstly. // Gets the texture by key firstly.
texture = Director::getInstance()->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY); texture = _director->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY);
// If texture wasn't in cache, create it from RAW data. // If texture wasn't in cache, create it from RAW data.
if (texture == nullptr) if (texture == nullptr)
@ -369,7 +385,7 @@ void Sprite::setTexture(Texture2D *texture)
CC_UNUSED_PARAM(isOK); CC_UNUSED_PARAM(isOK);
CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully.");
texture = Director::getInstance()->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY); texture = _director->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY);
CC_SAFE_RELEASE(image); CC_SAFE_RELEASE(image);
} }
} }
@ -451,14 +467,14 @@ void Sprite::setVertexRect(const Rect& rect)
void Sprite::setTextureCoords(Rect rect) void Sprite::setTextureCoords(Rect rect)
{ {
rect = CC_RECT_POINTS_TO_PIXELS(rect);
Texture2D *tex = _batchNode ? _textureAtlas->getTexture() : _texture; Texture2D *tex = _batchNode ? _textureAtlas->getTexture() : _texture;
if (! tex) if (tex == nullptr)
{ {
return; return;
} }
rect = CC_RECT_POINTS_TO_PIXELS(rect);
float atlasWidth = (float)tex->getPixelsWide(); float atlasWidth = (float)tex->getPixelsWide();
float atlasHeight = (float)tex->getPixelsHigh(); float atlasHeight = (float)tex->getPixelsHigh();
@ -637,6 +653,11 @@ void Sprite::updateTransform(void)
void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{ {
if (_texture == nullptr)
{
return;
}
#if CC_USE_CULLING #if CC_USE_CULLING
// Don't do calculate the culling if the transform was not updated // Don't do calculate the culling if the transform was not updated
auto visitingCamera = Camera::getVisitingCamera(); auto visitingCamera = Camera::getVisitingCamera();
@ -684,6 +705,10 @@ void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
void Sprite::addChild(Node *child, int zOrder, int tag) void Sprite::addChild(Node *child, int zOrder, int tag)
{ {
CCASSERT(child != nullptr, "Argument must be non-nullptr"); CCASSERT(child != nullptr, "Argument must be non-nullptr");
if (child == nullptr)
{
return;
}
if (_batchNode) if (_batchNode)
{ {
@ -705,6 +730,10 @@ void Sprite::addChild(Node *child, int zOrder, int tag)
void Sprite::addChild(Node *child, int zOrder, const std::string &name) void Sprite::addChild(Node *child, int zOrder, const std::string &name)
{ {
CCASSERT(child != nullptr, "Argument must be non-nullptr"); CCASSERT(child != nullptr, "Argument must be non-nullptr");
if (child == nullptr)
{
return;
}
if (_batchNode) if (_batchNode)
{ {
@ -1012,6 +1041,12 @@ bool Sprite::isOpacityModifyRGB(void) const
void Sprite::setSpriteFrame(const std::string &spriteFrameName) void Sprite::setSpriteFrame(const std::string &spriteFrameName)
{ {
CCASSERT(!spriteFrameName.empty(), "spriteFrameName must not be empty");
if (spriteFrameName.empty())
{
return;
}
SpriteFrameCache *cache = SpriteFrameCache::getInstance(); SpriteFrameCache *cache = SpriteFrameCache::getInstance();
SpriteFrame *spriteFrame = cache->getSpriteFrameByName(spriteFrameName); SpriteFrame *spriteFrame = cache->getSpriteFrameByName(spriteFrameName);
@ -1051,7 +1086,11 @@ void Sprite::setSpriteFrame(SpriteFrame *spriteFrame)
void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex) void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex)
{ {
CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be nullptr"); CCASSERT(!animationName.empty(), "CCSprite#setDisplayFrameWithAnimationName. animationName must not be nullptr");
if (animationName.empty())
{
return;
}
Animation *a = AnimationCache::getInstance()->getAnimation(animationName); Animation *a = AnimationCache::getInstance()->getAnimation(animationName);

View File

@ -45,10 +45,14 @@ NS_CC_BEGIN
SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capacity/* = DEFAULT_CAPACITY*/) SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capacity/* = DEFAULT_CAPACITY*/)
{ {
SpriteBatchNode *batchNode = new (std::nothrow) SpriteBatchNode(); SpriteBatchNode *batchNode = new (std::nothrow) SpriteBatchNode();
batchNode->initWithTexture(tex, capacity); if(batchNode && batchNode->initWithTexture(tex, capacity))
batchNode->autorelease(); {
batchNode->autorelease();
return batchNode;
}
return batchNode; delete batchNode;
return nullptr;
} }
/* /*
@ -58,10 +62,14 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capa
SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/) SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/)
{ {
SpriteBatchNode *batchNode = new (std::nothrow) SpriteBatchNode(); SpriteBatchNode *batchNode = new (std::nothrow) SpriteBatchNode();
batchNode->initWithFile(fileImage, capacity); if(batchNode && batchNode->initWithFile(fileImage, capacity))
batchNode->autorelease(); {
batchNode->autorelease();
return batchNode;
}
return batchNode; delete batchNode;
return nullptr;
} }
/* /*
@ -69,6 +77,11 @@ SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t c
*/ */
bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAULT_CAPACITY*/) bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAULT_CAPACITY*/)
{ {
if(tex == nullptr)
{
return false;
}
CCASSERT(capacity>=0, "Capacity must be >= 0"); CCASSERT(capacity>=0, "Capacity must be >= 0");
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
@ -78,7 +91,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAU
} }
_textureAtlas = new (std::nothrow) TextureAtlas(); _textureAtlas = new (std::nothrow) TextureAtlas();
if (capacity == 0) if (capacity <= 0)
{ {
capacity = DEFAULT_CAPACITY; capacity = DEFAULT_CAPACITY;
} }
@ -148,13 +161,12 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uin
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
Director* director = Director::getInstance(); _director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
draw(renderer, _modelViewTransform, flags); draw(renderer, _modelViewTransform, flags);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
// FIX ME: Why need to set _orderOfArrival to 0?? // FIX ME: Why need to set _orderOfArrival to 0??
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920 // Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
// setOrderOfArrival(0); // setOrderOfArrival(0);

View File

@ -113,7 +113,7 @@ void SpriteFrameCache::initializePolygonInfo(const Size &textureSize,
float scaleFactor = CC_CONTENT_SCALE_FACTOR(); float scaleFactor = CC_CONTENT_SCALE_FACTOR();
V3F_C4B_T2F *vertexData = new V3F_C4B_T2F[vertexCount]; V3F_C4B_T2F *vertexData = new (std::nothrow) V3F_C4B_T2F[vertexCount];
for (size_t i = 0; i < vertexCount/2; i++) for (size_t i = 0; i < vertexCount/2; i++)
{ {
vertexData[i].colors = Color4B::WHITE; vertexData[i].colors = Color4B::WHITE;
@ -282,7 +282,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
if(flag) if(flag)
{ {
if (image == nullptr) { if (image == nullptr) {
image = new Image(); image = new (std::nothrow) Image();
image->initWithImageFile(textureFileName); image->initWithImageFile(textureFileName);
} }
parser.setSpriteFrameInfo(image, spriteFrame->getRectInPixels(), spriteFrame->isRotated()); parser.setSpriteFrameInfo(image, spriteFrame->getRectInPixels(), spriteFrame->isRotated());

View File

@ -1131,7 +1131,7 @@ bool Bundle3D::loadBinary(const std::string& path)
bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas) bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas)
{ {
const rapidjson::Value& mesh_data_array = _jsonReader[MESH]; const rapidjson::Value& mesh_data_array = _jsonReader[MESH];
MeshData* meshdata= new MeshData(); MeshData* meshdata= new (std::nothrow) MeshData();
const rapidjson::Value& mesh_data_val = mesh_data_array[(rapidjson::SizeType)0]; const rapidjson::Value& mesh_data_val = mesh_data_array[(rapidjson::SizeType)0];
const rapidjson::Value& mesh_data_body_array = mesh_data_val[DEFAULTPART]; const rapidjson::Value& mesh_data_body_array = mesh_data_val[DEFAULTPART];
@ -1179,7 +1179,7 @@ bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas)
bool Bundle3D::loadMeshDataJson_0_2(MeshDatas& meshdatas) bool Bundle3D::loadMeshDataJson_0_2(MeshDatas& meshdatas)
{ {
MeshData* meshdata= new MeshData(); MeshData* meshdata= new (std::nothrow) MeshData();
const rapidjson::Value& mesh_array = _jsonReader[MESH]; const rapidjson::Value& mesh_array = _jsonReader[MESH];
const rapidjson::Value& mesh_array_0 = mesh_array[(rapidjson::SizeType)0]; const rapidjson::Value& mesh_array_0 = mesh_array[(rapidjson::SizeType)0];

View File

@ -364,6 +364,13 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c
{ {
sprite->setName(nodedata->id); sprite->setName(nodedata->id);
auto mesh = Mesh::create(nodedata->id, getMeshIndexData(modeldata->subMeshId)); auto mesh = Mesh::create(nodedata->id, getMeshIndexData(modeldata->subMeshId));
if (_skeleton && modeldata->bones.size())
{
auto skin = MeshSkin::create(_skeleton, modeldata->bones, modeldata->invBindPose);
mesh->setSkin(skin);
}
if (modeldata->matrialId == "" && materialdatas.materials.size()) if (modeldata->matrialId == "" && materialdatas.materials.size())
{ {
const NTextureData* textureData = materialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse); const NTextureData* textureData = materialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse);
@ -748,7 +755,7 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{ {
#if CC_USE_CULLING #if CC_USE_CULLING
// camera clipping // camera clipping
if(Camera::getVisitingCamera() && !Camera::getVisitingCamera()->isVisibleInFrustum(&this->getAABB())) if(_children.size() == 0 && Camera::getVisitingCamera() && !Camera::getVisitingCamera()->isVisibleInFrustum(&getAABB()))
return; return;
#endif #endif

View File

@ -225,7 +225,7 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
bool Terrain::initHeightMap(const std::string& heightMap) bool Terrain::initHeightMap(const std::string& heightMap)
{ {
_heightMapImage = new Image(); _heightMapImage = new (std::nothrow) Image();
_heightMapImage->initWithImageFile(heightMap); _heightMapImage->initWithImageFile(heightMap);
_data = _heightMapImage->getData(); _data = _heightMapImage->getData();
_imageWidth =_heightMapImage->getWidth(); _imageWidth =_heightMapImage->getWidth();
@ -244,7 +244,7 @@ bool Terrain::initHeightMap(const std::string& heightMap)
{ {
for(int n =0; n<chunk_amount_x;n++) for(int n =0; n<chunk_amount_x;n++)
{ {
_chunkesArray[m][n] = new Chunk(); _chunkesArray[m][n] = new (std::nothrow) Chunk();
_chunkesArray[m][n]->_terrain = this; _chunkesArray[m][n]->_terrain = this;
_chunkesArray[m][n]->_size = _chunkSize; _chunkesArray[m][n]->_size = _chunkSize;
_chunkesArray[m][n]->generate(_imageWidth,_imageHeight,m,n,_data); _chunkesArray[m][n]->generate(_imageWidth,_imageHeight,m,n,_data);
@ -262,7 +262,7 @@ bool Terrain::initHeightMap(const std::string& heightMap)
if(m+1<chunk_amount_y) _chunkesArray[m][n]->_front = _chunkesArray[m+1][n]; if(m+1<chunk_amount_y) _chunkesArray[m][n]->_front = _chunkesArray[m+1][n];
} }
} }
_quadRoot = new QuadTree(0,0,_imageWidth,_imageHeight,this); _quadRoot = new (std::nothrow) QuadTree(0,0,_imageWidth,_imageHeight,this);
setLODDistance(_chunkSize.width,2*_chunkSize.width,3*_chunkSize.width); setLODDistance(_chunkSize.width,2*_chunkSize.width,3*_chunkSize.width);
return true; return true;
}else }else
@ -1487,13 +1487,13 @@ Terrain::QuadTree::QuadTree(int x, int y, int w, int h, Terrain * terrain)
if(_width> terrain->_chunkSize.width &&_height >terrain->_chunkSize.height) //subdivision if(_width> terrain->_chunkSize.width &&_height >terrain->_chunkSize.height) //subdivision
{ {
_isTerminal = false; _isTerminal = false;
this->_tl = new QuadTree(x,y,_width/2,_height/2,terrain); this->_tl = new (std::nothrow) QuadTree(x,y,_width/2,_height/2,terrain);
this->_tl->_parent = this; this->_tl->_parent = this;
this->_tr = new QuadTree(x+_width/2,y,_width/2,_height/2,terrain); this->_tr = new (std::nothrow) QuadTree(x+_width/2,y,_width/2,_height/2,terrain);
this->_tr->_parent = this; this->_tr->_parent = this;
this->_bl = new QuadTree(x,y+_height/2,_width/2,_height/2,terrain); this->_bl = new (std::nothrow) QuadTree(x,y+_height/2,_width/2,_height/2,terrain);
this->_bl->_parent = this; this->_bl->_parent = this;
this->_br = new QuadTree(x+_width/2,y+_height/2,_width/2,_height/2,terrain); this->_br = new (std::nothrow) QuadTree(x+_width/2,y+_height/2,_width/2,_height/2,terrain);
this->_br->_parent = this; this->_br->_parent = this;
_localAABB.merge(_tl->_localAABB); _localAABB.merge(_tl->_localAABB);

View File

@ -57,7 +57,7 @@ Configuration::Configuration()
, _maxSpotLightInShader(1) , _maxSpotLightInShader(1)
, _animate3DQuality(Animate3DQuality::QUALITY_LOW) , _animate3DQuality(Animate3DQuality::QUALITY_LOW)
{ {
_loadedEvent = new EventCustom(CONFIG_FILE_LOADED); _loadedEvent = new (std::nothrow) EventCustom(CONFIG_FILE_LOADED);
} }
bool Configuration::init() bool Configuration::init()

View File

@ -126,7 +126,7 @@ bool Director::init(void)
_frameRate = 0.0f; _frameRate = 0.0f;
_FPSLabel = _drawnBatchesLabel = _drawnVerticesLabel = nullptr; _FPSLabel = _drawnBatchesLabel = _drawnVerticesLabel = nullptr;
_totalFrames = 0; _totalFrames = 0;
_lastUpdate = new struct timeval; _lastUpdate = new (std::nothrow) struct timeval;
_secondsPerFrame = 1.0f; _secondsPerFrame = 1.0f;
// paused ? // paused ?

View File

@ -153,7 +153,7 @@ void EventDispatcher::EventListenerVector::push_back(EventListener* listener)
{ {
if (_sceneGraphListeners == nullptr) if (_sceneGraphListeners == nullptr)
{ {
_sceneGraphListeners = new std::vector<EventListener*>(); _sceneGraphListeners = new (std::nothrow) std::vector<EventListener*>();
_sceneGraphListeners->reserve(100); _sceneGraphListeners->reserve(100);
} }
@ -412,7 +412,7 @@ void EventDispatcher::associateNodeAndEventListener(Node* node, EventListener* l
} }
else else
{ {
listeners = new std::vector<EventListener*>(); listeners = new (std::nothrow) std::vector<EventListener*>();
_nodeListenersMap.insert(std::make_pair(node, listeners)); _nodeListenersMap.insert(std::make_pair(node, listeners));
} }

View File

@ -383,7 +383,7 @@ void Scheduler::unschedule(const std::string &key, void *target)
void Scheduler::priorityIn(tListEntry **list, const ccSchedulerFunc& callback, void *target, int priority, bool paused) void Scheduler::priorityIn(tListEntry **list, const ccSchedulerFunc& callback, void *target, int priority, bool paused)
{ {
tListEntry *listElement = new tListEntry(); tListEntry *listElement = new (std::nothrow) tListEntry();
listElement->callback = callback; listElement->callback = callback;
listElement->target = target; listElement->target = target;
@ -440,7 +440,7 @@ void Scheduler::priorityIn(tListEntry **list, const ccSchedulerFunc& callback, v
void Scheduler::appendIn(_listEntry **list, const ccSchedulerFunc& callback, void *target, bool paused) void Scheduler::appendIn(_listEntry **list, const ccSchedulerFunc& callback, void *target, bool paused)
{ {
tListEntry *listElement = new tListEntry(); tListEntry *listElement = new (std::nothrow) tListEntry();
listElement->callback = callback; listElement->callback = callback;
listElement->target = target; listElement->target = target;

View File

@ -74,7 +74,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
do do
{ {
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
*doc = xmlDoc; *doc = xmlDoc;
ssize_t size; ssize_t size;

View File

@ -75,7 +75,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
do do
{ {
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
*doc = xmlDoc; *doc = xmlDoc;
std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath()); std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath());

View File

@ -57,7 +57,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle
do do
{ {
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
*doc = xmlDoc; *doc = xmlDoc;
std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath()); std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath());
@ -467,7 +467,7 @@ void UserDefault::initXMLFilePath()
bool UserDefault::createXMLFile() bool UserDefault::createXMLFile()
{ {
bool bRet = false; bool bRet = false;
tinyxml2::XMLDocument *pDoc = new tinyxml2::XMLDocument(); tinyxml2::XMLDocument *pDoc = new (std::nothrow) tinyxml2::XMLDocument();
if (nullptr==pDoc) if (nullptr==pDoc)
{ {
return false; return false;

View File

@ -74,7 +74,7 @@ Value::Value(bool v)
Value::Value(const char* v) Value::Value(const char* v)
: _type(Type::STRING) : _type(Type::STRING)
{ {
_field.strVal = new std::string(); _field.strVal = new (std::nothrow) std::string();
if (v) if (v)
{ {
*_field.strVal = v; *_field.strVal = v;
@ -84,7 +84,7 @@ Value::Value(const char* v)
Value::Value(const std::string& v) Value::Value(const std::string& v)
: _type(Type::STRING) : _type(Type::STRING)
{ {
_field.strVal = new std::string(); _field.strVal = new (std::nothrow) std::string();
*_field.strVal = v; *_field.strVal = v;
} }
@ -813,7 +813,7 @@ void Value::reset(Type type)
switch (type) switch (type)
{ {
case Type::STRING: case Type::STRING:
_field.strVal = new std::string(); _field.strVal = new (std::nothrow) std::string();
break; break;
case Type::VECTOR: case Type::VECTOR:
_field.vectorVal = new (std::nothrow) ValueVector(); _field.vectorVal = new (std::nothrow) ValueVector();

View File

@ -518,7 +518,7 @@ public:
ZipFile *ZipFile::createWithBuffer(const void* buffer, uLong size) ZipFile *ZipFile::createWithBuffer(const void* buffer, uLong size)
{ {
ZipFile *zip = new ZipFile(); ZipFile *zip = new (std::nothrow) ZipFile();
if (zip && zip->initWithBuffer(buffer, size)) { if (zip && zip->initWithBuffer(buffer, size)) {
return zip; return zip;
} else { } else {

View File

@ -293,7 +293,7 @@ unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1*/, int*
if (succeed) if (succeed)
{ {
ret = new unsigned short[outUtf16.length() + 1]; ret = new (std::nothrow) unsigned short[outUtf16.length() + 1];
ret[outUtf16.length()] = 0; ret[outUtf16.length()] = 0;
memcpy(ret, outUtf16.data(), outUtf16.length() * sizeof(unsigned short)); memcpy(ret, outUtf16.data(), outUtf16.length() * sizeof(unsigned short));
if (rUtf16Size) if (rUtf16Size)
@ -328,7 +328,7 @@ char * cc_utf16_to_utf8 (const unsigned short *str,
if (succeed) if (succeed)
{ {
ret = new char[outUtf8.length() + 1]; ret = new (std::nothrow) char[outUtf8.length() + 1];
ret[outUtf8.length()] = '\0'; ret[outUtf8.length()] = '\0';
memcpy(ret, outUtf8.data(), outUtf8.length()); memcpy(ret, outUtf8.data(), outUtf8.length());
} }

View File

@ -271,12 +271,12 @@ Sprite* createSpriteFromBase64(const char* base64String)
unsigned char* decoded; unsigned char* decoded;
int length = base64Decode((const unsigned char*) base64String, (unsigned int) strlen(base64String), &decoded); int length = base64Decode((const unsigned char*) base64String, (unsigned int) strlen(base64String), &decoded);
Image *image = new Image(); Image *image = new (std::nothrow) Image();
bool imageResult = image->initWithImageData(decoded, length); bool imageResult = image->initWithImageData(decoded, length);
CCASSERT(imageResult, "Failed to create image from base64!"); CCASSERT(imageResult, "Failed to create image from base64!");
free(decoded); free(decoded);
Texture2D *texture = new Texture2D(); Texture2D *texture = new (std::nothrow) Texture2D();
texture->initWithImage(image); texture->initWithImage(image);
texture->setAliasTexParameters(); texture->setAliasTexParameters();
image->release(); image->release();

View File

@ -44,7 +44,7 @@ __Array::__Array()
__Array* __Array::create() __Array* __Array::create()
{ {
__Array* array = new __Array(); __Array* array = new (std::nothrow) __Array();
if (array && array->initWithCapacity(7)) if (array && array->initWithCapacity(7))
{ {
@ -60,7 +60,7 @@ __Array* __Array::create()
__Array* __Array::createWithObject(Ref* object) __Array* __Array::createWithObject(Ref* object)
{ {
__Array* array = new __Array(); __Array* array = new (std::nothrow) __Array();
if (array && array->initWithObject(object)) if (array && array->initWithObject(object))
{ {
@ -109,7 +109,7 @@ __Array* __Array::createWithCapacity(int capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
__Array* array = new __Array(); __Array* array = new (std::nothrow) __Array();
if (array && array->initWithCapacity(capacity)) if (array && array->initWithCapacity(capacity))
{ {
@ -342,7 +342,7 @@ __Array::~Array()
__Array* __Array::clone() const __Array* __Array::clone() const
{ {
__Array* ret = new __Array(); __Array* ret = new (std::nothrow) __Array();
ret->autorelease(); ret->autorelease();
ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1); ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1);
@ -387,7 +387,7 @@ __Array::__Array()
__Array* __Array::create() __Array* __Array::create()
{ {
__Array* array = new __Array(); __Array* array = new (std::nothrow) __Array();
if (array && array->initWithCapacity(7)) if (array && array->initWithCapacity(7))
{ {
@ -403,7 +403,7 @@ __Array* __Array::create()
__Array* __Array::createWithObject(Ref* object) __Array* __Array::createWithObject(Ref* object)
{ {
__Array* array = new __Array(); __Array* array = new (std::nothrow) __Array();
if (array && array->initWithObject(object)) if (array && array->initWithObject(object))
{ {
@ -452,7 +452,7 @@ __Array* __Array::createWithCapacity(ssize_t capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
__Array* array = new __Array(); __Array* array = new (std::nothrow) __Array();
if (array && array->initWithCapacity(capacity)) if (array && array->initWithCapacity(capacity))
{ {
@ -728,7 +728,7 @@ __Array::~__Array()
__Array* __Array::clone() const __Array* __Array::clone() const
{ {
__Array* ret = new __Array(); __Array* ret = new (std::nothrow) __Array();
ret->autorelease(); ret->autorelease();
ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1); ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1);

View File

@ -46,7 +46,7 @@ public:
static __Bool* create(bool v) static __Bool* create(bool v)
{ {
__Bool* pRet = new __Bool(v); __Bool* pRet = new (std::nothrow) __Bool(v);
if (pRet) if (pRet)
{ {
pRet->autorelease(); pRet->autorelease();

View File

@ -106,7 +106,7 @@ __Array* __Dictionary::allKeys()
{ {
HASH_ITER(hh, _elements, pElement, tmp) HASH_ITER(hh, _elements, pElement, tmp)
{ {
__String* pOneKey = new __String(pElement->_strKey); __String* pOneKey = new (std::nothrow) __String(pElement->_strKey);
array->addObject(pOneKey); array->addObject(pOneKey);
CC_SAFE_RELEASE(pOneKey); CC_SAFE_RELEASE(pOneKey);
} }
@ -115,7 +115,7 @@ __Array* __Dictionary::allKeys()
{ {
HASH_ITER(hh, _elements, pElement, tmp) HASH_ITER(hh, _elements, pElement, tmp)
{ {
__Integer* pOneKey = new __Integer(static_cast<int>(pElement->_intKey)); __Integer* pOneKey = new (std::nothrow) __Integer(static_cast<int>(pElement->_intKey));
array->addObject(pOneKey); array->addObject(pOneKey);
CC_SAFE_RELEASE(pOneKey); CC_SAFE_RELEASE(pOneKey);
} }
@ -138,7 +138,7 @@ __Array* __Dictionary::allKeysForObject(Ref* object)
{ {
if (object == pElement->_object) if (object == pElement->_object)
{ {
__String* pOneKey = new __String(pElement->_strKey); __String* pOneKey = new (std::nothrow) __String(pElement->_strKey);
array->addObject(pOneKey); array->addObject(pOneKey);
CC_SAFE_RELEASE(pOneKey); CC_SAFE_RELEASE(pOneKey);
} }
@ -150,7 +150,7 @@ __Array* __Dictionary::allKeysForObject(Ref* object)
{ {
if (object == pElement->_object) if (object == pElement->_object)
{ {
__Integer* pOneKey = new __Integer(static_cast<int>(pElement->_intKey)); __Integer* pOneKey = new (std::nothrow) __Integer(static_cast<int>(pElement->_intKey));
array->addObject(pOneKey); array->addObject(pOneKey);
CC_SAFE_RELEASE(pOneKey); CC_SAFE_RELEASE(pOneKey);
} }
@ -366,7 +366,7 @@ Ref* __Dictionary::randomObject()
__Dictionary* __Dictionary::create() __Dictionary* __Dictionary::create()
{ {
__Dictionary* ret = new __Dictionary(); __Dictionary* ret = new (std::nothrow) __Dictionary();
if (ret && ret->init() ) if (ret && ret->init() )
{ {
ret->autorelease(); ret->autorelease();
@ -388,7 +388,7 @@ static __Array* visitArray(const ValueVector& array);
static __Dictionary* visitDict(const ValueMap& dict) static __Dictionary* visitDict(const ValueMap& dict)
{ {
__Dictionary* ret = new __Dictionary(); __Dictionary* ret = new (std::nothrow) __Dictionary();
ret->init(); ret->init();
for (auto iter = dict.begin(); iter != dict.end(); ++iter) for (auto iter = dict.begin(); iter != dict.end(); ++iter)
@ -409,7 +409,7 @@ static __Dictionary* visitDict(const ValueMap& dict)
} }
else else
{ {
auto str = new __String(iter->second.asString()); auto str = new (std::nothrow) __String(iter->second.asString());
ret->setObject(str, iter->first); ret->setObject(str, iter->first);
str->release(); str->release();
} }
@ -419,7 +419,7 @@ static __Dictionary* visitDict(const ValueMap& dict)
static __Array* visitArray(const ValueVector& array) static __Array* visitArray(const ValueVector& array)
{ {
__Array* ret = new __Array(); __Array* ret = new (std::nothrow) __Array();
ret->init(); ret->init();
for(const auto &value : array) { for(const auto &value : array) {
@ -439,7 +439,7 @@ static __Array* visitArray(const ValueVector& array)
} }
else else
{ {
auto str = new __String(value.asString()); auto str = new (std::nothrow) __String(value.asString());
ret->addObject(str); ret->addObject(str);
str->release(); str->release();
} }

View File

@ -45,7 +45,7 @@ public:
static __Double* create(double v) static __Double* create(double v)
{ {
__Double* pRet = new __Double(v); __Double* pRet = new (std::nothrow) __Double(v);
if (pRet) if (pRet)
{ {
pRet->autorelease(); pRet->autorelease();

View File

@ -45,7 +45,7 @@ public:
static __Float* create(float v) static __Float* create(float v)
{ {
__Float* pRet = new __Float(v); __Float* pRet = new (std::nothrow) __Float(v);
if (pRet) if (pRet)
{ {
pRet->autorelease(); pRet->autorelease();

View File

@ -43,7 +43,7 @@ class CC_DLL __Integer : public Ref, public Clonable
public: public:
static __Integer* create(int v) static __Integer* create(int v)
{ {
__Integer* pRet = new __Integer(v); __Integer* pRet = new (std::nothrow) __Integer(v);
pRet->autorelease(); pRet->autorelease();
return pRet; return pRet;
} }

View File

@ -53,7 +53,7 @@ __NotificationCenter *__NotificationCenter::getInstance()
{ {
if (!s_sharedNotifCenter) if (!s_sharedNotifCenter)
{ {
s_sharedNotifCenter = new __NotificationCenter; s_sharedNotifCenter = new (std::nothrow) __NotificationCenter;
} }
return s_sharedNotifCenter; return s_sharedNotifCenter;
} }

View File

@ -31,12 +31,12 @@ NS_CC_BEGIN
__Set::__Set(void) __Set::__Set(void)
{ {
_set = new set<Ref *>; _set = new (std::nothrow) set<Ref *>;
} }
__Set::__Set(const __Set &other) __Set::__Set(const __Set &other)
{ {
_set = new set<Ref *>(*other._set); _set = new (std::nothrow) set<Ref *>(*other._set);
// call retain of members // call retain of members
__SetIterator iter; __SetIterator iter;
@ -64,7 +64,7 @@ void __Set::acceptVisitor(DataVisitor &visitor)
__Set * __Set::create() __Set * __Set::create()
{ {
__Set * pRet = new __Set(); __Set * pRet = new (std::nothrow) __Set();
if (pRet != nullptr) if (pRet != nullptr)
{ {
@ -76,7 +76,7 @@ __Set * __Set::create()
__Set* __Set::copy(void) __Set* __Set::copy(void)
{ {
__Set *p__Set = new __Set(*this); __Set *p__Set = new (std::nothrow) __Set(*this);
return p__Set; return p__Set;
} }

View File

@ -220,7 +220,7 @@ bool __String::isEqual(const Ref* pObject)
__String* __String::create(const std::string& str) __String* __String::create(const std::string& str)
{ {
__String* ret = new __String(str); __String* ret = new (std::nothrow) __String(str);
ret->autorelease(); ret->autorelease();
return ret; return ret;
} }

View File

@ -468,7 +468,7 @@ float * NodeLoader::parsePropTypeFloatXY(Node * pNode, Node * pParent, CCBReader
float x = ccbReader->readFloat(); float x = ccbReader->readFloat();
float y = ccbReader->readFloat(); float y = ccbReader->readFloat();
float * floatXY = new float[2]; float * floatXY = new (std::nothrow) float[2];
floatXY[0] = x; floatXY[0] = x;
floatXY[1] = y; floatXY[1] = y;
@ -499,7 +499,7 @@ float * NodeLoader::parsePropTypeScaleLock(Node * pNode, Node * pParent, CCBRead
y *= ccbReader->getResolutionScale(); y *= ccbReader->getResolutionScale();
} }
float * scaleLock = new float[2]; float * scaleLock = new (std::nothrow) float[2];
scaleLock[0] = x; scaleLock[0] = x;
scaleLock[1] = y; scaleLock[1] = y;
@ -549,7 +549,7 @@ float * NodeLoader::parsePropTypeFloatVar(Node * pNode, Node * pParent, CCBReade
float f = ccbReader->readFloat(); float f = ccbReader->readFloat();
float fVar = ccbReader->readFloat(); float fVar = ccbReader->readFloat();
float * arr = new float[2]; float * arr = new (std::nothrow) float[2];
arr[0] = f; arr[0] = f;
arr[1] = fVar; arr[1] = fVar;
@ -705,7 +705,7 @@ bool * NodeLoader::parsePropTypeFlip(Node * pNode, Node * pParent, CCBReader * c
bool flipX = ccbReader->readBool(); bool flipX = ccbReader->readBool();
bool flipY = ccbReader->readBool(); bool flipY = ccbReader->readBool();
bool * arr = new bool[2]; bool * arr = new (std::nothrow) bool[2];
arr[0] = flipX; arr[0] = flipX;
arr[1] = flipY; arr[1] = flipY;

View File

@ -171,7 +171,7 @@ CSLoader* CSLoader::getInstance()
{ {
if (! _sharedCSLoader) if (! _sharedCSLoader)
{ {
_sharedCSLoader = new CSLoader(); _sharedCSLoader = new (std::nothrow) CSLoader();
_sharedCSLoader->init(); _sharedCSLoader->init();
} }
@ -742,7 +742,7 @@ Node* CSLoader::loadWidget(const rapidjson::Value& json)
WidgetPropertiesReader0300* widgetPropertiesReader = new WidgetPropertiesReader0300(); WidgetPropertiesReader0300* widgetPropertiesReader = new (std::nothrow) WidgetPropertiesReader0300();
Widget* widget = nullptr; Widget* widget = nullptr;
if (isWidget(classname)) if (isWidget(classname))

View File

@ -421,7 +421,7 @@ void ColliderDetector::setBody(b2Body *pBody)
ContourData *contourData = colliderBody->getContourData(); ContourData *contourData = colliderBody->getContourData();
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.size()]; b2Vec2 *b2bv = new (std::nothrow) b2Vec2[contourData->vertexList.size()];
int i = 0; int i = 0;
for(auto& v : contourData->vertexList) for(auto& v : contourData->vertexList)
@ -470,7 +470,7 @@ void ColliderDetector::setBody(cpBody *pBody)
ssize_t num = contourData->vertexList.size(); ssize_t num = contourData->vertexList.size();
auto vs = contourData->vertexList; auto vs = contourData->vertexList;
cpVect *verts = new cpVect[num]; cpVect *verts = new (std::nothrow) cpVect[num];
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
verts[num - 1 - i].x = vs.at(i).x; verts[num - 1 - i].x = vs.at(i).x;

View File

@ -373,7 +373,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const
if (_asyncStructQueue == nullptr) if (_asyncStructQueue == nullptr)
{ {
_asyncStructQueue = new std::queue<AsyncStruct *>(); _asyncStructQueue = new std::queue<AsyncStruct *>();
_dataQueue = new std::queue<DataInfo *>(); _dataQueue = new (std::nothrow) std::queue<DataInfo *>();
// create a new thread to load images // create a new thread to load images
_loadingThread = new std::thread(&DataReaderHelper::loadData, this); _loadingThread = new std::thread(&DataReaderHelper::loadData, this);
@ -1644,7 +1644,7 @@ FrameData *DataReaderHelper::decodeFrame(const rapidjson::Value& json, DataInfo
int length = DICTOOL->getArrayCount_json(json, A_EASING_PARAM); int length = DICTOOL->getArrayCount_json(json, A_EASING_PARAM);
if (length != 0) if (length != 0)
{ {
frameData->easingParams = new float[length]; frameData->easingParams = new (std::nothrow) float[length];
frameData->easingParamNumber = length; frameData->easingParamNumber = length;
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
@ -2384,7 +2384,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
int count = pFrameDataArray[i].GetChildNum(); int count = pFrameDataArray[i].GetChildNum();
if (count != 0 ) if (count != 0 )
{ {
frameData->easingParams = new float[count]; frameData->easingParams = new (std::nothrow) float[count];
stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray(cocoLoader); stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray(cocoLoader);
for (int ii = 0; ii < count; ++ii) for (int ii = 0; ii < count; ++ii)
{ {

View File

@ -283,7 +283,7 @@ void FrameData::copy(const BaseData *baseData)
CC_SAFE_DELETE(easingParams); CC_SAFE_DELETE(easingParams);
if (easingParamNumber != 0) if (easingParamNumber != 0)
{ {
easingParams = new float[easingParamNumber]; easingParams = new (std::nothrow) float[easingParamNumber];
for (int i = 0; i<easingParamNumber; i++) for (int i = 0; i<easingParamNumber; i++)
{ {
easingParams[i] = frameData->easingParams[i]; easingParams[i] = frameData->easingParams[i];

View File

@ -39,7 +39,7 @@ THE SOFTWARE.
#define CC_CREATE_NO_PARAM_NO_INIT(varType)\ #define CC_CREATE_NO_PARAM_NO_INIT(varType)\
public: \ public: \
static inline varType *create(void){ \ static inline varType *create(void){ \
varType *var = new varType();\ varType *var = new (std::nothrow) varType();\
if (var)\ if (var)\
{\ {\
var->autorelease();\ var->autorelease();\
@ -52,7 +52,7 @@ public: \
#define CC_CREATE_NO_PARAM(varType)\ #define CC_CREATE_NO_PARAM(varType)\
public: \ public: \
static inline varType *create(void){ \ static inline varType *create(void){ \
varType *var = new varType();\ varType *var = new (std::nothrow) varType();\
if (var && var->init())\ if (var && var->init())\
{\ {\
var->autorelease();\ var->autorelease();\

View File

@ -177,7 +177,7 @@ bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
pTempBuff += sizeof(stCocoFileHeader); pTempBuff += sizeof(stCocoFileHeader);
char* pStartAddr = m_pMemoryBuff = pTempBuff; char* pStartAddr = m_pMemoryBuff = pTempBuff;
char* pDestBuff = new char[m_pFileHeader->m_nDataSize]; char* pDestBuff = new (std::nothrow) char[m_pFileHeader->m_nDataSize];
if (m_pFileHeader->m_nCompressSize > 0) if (m_pFileHeader->m_nCompressSize > 0)
{ {
uLongf dwSrcSize = m_pFileHeader->m_nCompressSize; uLongf dwSrcSize = m_pFileHeader->m_nCompressSize;

View File

@ -119,7 +119,7 @@ FlatBuffersSerialize* FlatBuffersSerialize::getInstance()
{ {
if (!_instanceFlatBuffersSerialize) if (!_instanceFlatBuffersSerialize)
{ {
_instanceFlatBuffersSerialize = new FlatBuffersSerialize(); _instanceFlatBuffersSerialize = new (std::nothrow) FlatBuffersSerialize();
} }
return _instanceFlatBuffersSerialize; return _instanceFlatBuffersSerialize;
@ -161,7 +161,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath); std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath);
// xml parse // xml parse
tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); tinyxml2::XMLDocument* document = new (std::nothrow) tinyxml2::XMLDocument();
document->Parse(content.c_str()); document->Parse(content.c_str());
const tinyxml2::XMLElement* rootElement = document->RootElement();// Root const tinyxml2::XMLElement* rootElement = document->RootElement();// Root
@ -238,7 +238,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
if (serializeEnabled) if (serializeEnabled)
{ {
_builder = new FlatBufferBuilder(); _builder = new (std::nothrow) FlatBufferBuilder();
Offset<NodeTree> nodeTree; Offset<NodeTree> nodeTree;
Offset<NodeAction> aciton; Offset<NodeAction> aciton;
@ -1292,7 +1292,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath); std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath);
// xml parse // xml parse
tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); tinyxml2::XMLDocument* document = new (std::nothrow) tinyxml2::XMLDocument();
document->Parse(content.c_str()); document->Parse(content.c_str());
const tinyxml2::XMLElement* rootElement = document->RootElement();// Root const tinyxml2::XMLElement* rootElement = document->RootElement();// Root
@ -1345,7 +1345,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
if (serializeEnabled) if (serializeEnabled)
{ {
_builder = new FlatBufferBuilder(); _builder = new (std::nothrow) FlatBufferBuilder();
Offset<NodeTree> nodeTree; Offset<NodeTree> nodeTree;
Offset<NodeAction> aciton; Offset<NodeAction> aciton;

View File

@ -29,10 +29,10 @@ using namespace cocostudio;
void sendEvent(unsigned int event) void sendEvent(unsigned int event)
{ {
char* buf = new char[10]; char buf[10];
sprintf(buf, "%d", event); sprintf(buf, "%d", event);
std::string custom_event_name(buf); std::string custom_event_name(buf);
CC_SAFE_DELETE_ARRAY(buf);
EventCustom eventCustom(custom_event_name); EventCustom eventCustom(custom_event_name);
TriggerMng::getInstance()->dispatchEvent(&eventCustom); TriggerMng::getInstance()->dispatchEvent(&eventCustom);
} }

View File

@ -40,7 +40,7 @@ THE SOFTWARE.
#define IMPLEMENT_CLASS_INFO(className) \ #define IMPLEMENT_CLASS_INFO(className) \
cocos2d::Ref* className::createInstance(void) \ cocos2d::Ref* className::createInstance(void) \
{ \ { \
auto ret = new className; \ auto ret = new (std::nothrow) className; \
ret->autorelease(); \ ret->autorelease(); \
return ret; \ return ret; \
} \ } \

View File

@ -491,7 +491,7 @@ void TriggerMng::addEventListenerWithFixedPriority(cocos2d::EventListener* liste
ArmatureMovementDispatcher::ArmatureMovementDispatcher(void) ArmatureMovementDispatcher::ArmatureMovementDispatcher(void)
: _mapEventAnimation(nullptr) : _mapEventAnimation(nullptr)
{ {
_mapEventAnimation = new std::unordered_map<Ref*, SEL_MovementEventCallFunc> ; _mapEventAnimation = new (std::nothrow) std::unordered_map<Ref*, SEL_MovementEventCallFunc> ;
} }
ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void) ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void)

View File

@ -224,10 +224,9 @@ void TriggerObj::serialize(const rapidjson::Value &val)
continue; continue;
} }
char* buf = new char[10]; char buf[10];
sprintf(buf, "%d", event); sprintf(buf, "%d", event);
std::string custom_event_name(buf); std::string custom_event_name(buf);
CC_SAFE_DELETE_ARRAY(buf);
EventListenerCustom* listener = EventListenerCustom::create(custom_event_name, [=](EventCustom* evt){ EventListenerCustom* listener = EventListenerCustom::create(custom_event_name, [=](EventCustom* evt){
if (detect()) if (detect())
@ -316,10 +315,9 @@ void TriggerObj::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stEx
{ {
continue; continue;
} }
char* buf = new char[10]; char buf[10];
sprintf(buf, "%d", event); sprintf(buf, "%d", event);
std::string custom_event_name(buf); std::string custom_event_name(buf);
CC_SAFE_DELETE_ARRAY(buf);
EventListenerCustom* listener = EventListenerCustom::create(custom_event_name, [=](EventCustom* evt){ EventListenerCustom* listener = EventListenerCustom::create(custom_event_name, [=](EventCustom* evt){
if (detect()) if (detect())

View File

@ -55,7 +55,7 @@ namespace cocostudio
{ {
if (!_instanceTMXTiledMapReader) if (!_instanceTMXTiledMapReader)
{ {
_instanceTMXTiledMapReader = new GameMapReader(); _instanceTMXTiledMapReader = new (std::nothrow) GameMapReader();
} }
return _instanceTMXTiledMapReader; return _instanceTMXTiledMapReader;

View File

@ -57,7 +57,7 @@ namespace cocostudio
{ {
if (!_instanceNode3DReader) if (!_instanceNode3DReader)
{ {
_instanceNode3DReader = new GameNode3DReader(); _instanceNode3DReader = new (std::nothrow) GameNode3DReader();
} }
return _instanceNode3DReader; return _instanceNode3DReader;

View File

@ -56,7 +56,7 @@ namespace cocostudio
{ {
if (!_instanceLight3DReader) if (!_instanceLight3DReader)
{ {
_instanceLight3DReader = new Light3DReader(); _instanceLight3DReader = new (std::nothrow) Light3DReader();
} }
return _instanceLight3DReader; return _instanceLight3DReader;

View File

@ -56,7 +56,7 @@ namespace cocostudio
{ {
if (!_instanceNode3DReader) if (!_instanceNode3DReader)
{ {
_instanceNode3DReader = new Node3DReader(); _instanceNode3DReader = new (std::nothrow) Node3DReader();
} }
return _instanceNode3DReader; return _instanceNode3DReader;

View File

@ -73,7 +73,7 @@ namespace cocostudio
{ {
if (!_instanceNodeReader) if (!_instanceNodeReader)
{ {
_instanceNodeReader = new NodeReader(); _instanceNodeReader = new (std::nothrow) NodeReader();
} }
return _instanceNodeReader; return _instanceNodeReader;

View File

@ -57,7 +57,7 @@ namespace cocostudio
{ {
if (!_instanceParticle3DReader) if (!_instanceParticle3DReader)
{ {
_instanceParticle3DReader = new Particle3DReader(); _instanceParticle3DReader = new (std::nothrow) Particle3DReader();
} }
return _instanceParticle3DReader; return _instanceParticle3DReader;

View File

@ -53,7 +53,7 @@ namespace cocostudio
{ {
if (!_instanceParticleReader) if (!_instanceParticleReader)
{ {
_instanceParticleReader = new ParticleReader(); _instanceParticleReader = new (std::nothrow) ParticleReader();
} }
return _instanceParticleReader; return _instanceParticleReader;

View File

@ -51,7 +51,7 @@ namespace cocostudio
{ {
if (!_instanceProjectNodeReader) if (!_instanceProjectNodeReader)
{ {
_instanceProjectNodeReader = new ProjectNodeReader(); _instanceProjectNodeReader = new (std::nothrow) ProjectNodeReader();
} }
return _instanceProjectNodeReader; return _instanceProjectNodeReader;

View File

@ -56,7 +56,7 @@ namespace cocostudio
{ {
if (!_instanceSingleNodeReader) if (!_instanceSingleNodeReader)
{ {
_instanceSingleNodeReader = new SingleNodeReader(); _instanceSingleNodeReader = new (std::nothrow) SingleNodeReader();
} }
return _instanceSingleNodeReader; return _instanceSingleNodeReader;

View File

@ -56,7 +56,7 @@ namespace cocostudio
{ {
if (!_instanceSprite3DReader) if (!_instanceSprite3DReader)
{ {
_instanceSprite3DReader = new Sprite3DReader(); _instanceSprite3DReader = new (std::nothrow) Sprite3DReader();
} }
return _instanceSprite3DReader; return _instanceSprite3DReader;

View File

@ -54,7 +54,7 @@ namespace cocostudio
{ {
if (!_instanceSpriteReader) if (!_instanceSpriteReader)
{ {
_instanceSpriteReader = new SpriteReader(); _instanceSpriteReader = new (std::nothrow) SpriteReader();
} }
return _instanceSpriteReader; return _instanceSpriteReader;

View File

@ -56,7 +56,7 @@ namespace cocostudio
{ {
if (!_instanceUserCameraReader) if (!_instanceUserCameraReader)
{ {
_instanceUserCameraReader = new UserCameraReader(); _instanceUserCameraReader = new (std::nothrow) UserCameraReader();
} }
return _instanceUserCameraReader; return _instanceUserCameraReader;

View File

@ -183,9 +183,9 @@ bool NavMesh::loadNavMeshFile()
return false; return false;
} }
_allocator = new LinearAllocator(32000); _allocator = new (std::nothrow) LinearAllocator(32000);
_compressor = new FastLZCompressor; _compressor = new (std::nothrow) FastLZCompressor;
_meshProcess = new MeshProcess(_geomData); _meshProcess = new (std::nothrow) MeshProcess(_geomData);
status = _tileCache->init(&header.cacheParams, _allocator, _compressor, _meshProcess); status = _tileCache->init(&header.cacheParams, _allocator, _compressor, _meshProcess);
if (dtStatusFailed(status)) if (dtStatusFailed(status))
@ -233,7 +233,7 @@ bool NavMesh::loadGeomFile()
auto data = FileUtils::getInstance()->getDataFromFile(_geomFilePath); auto data = FileUtils::getInstance()->getDataFromFile(_geomFilePath);
if (data.isNull()) return false; if (data.isNull()) return false;
buf = data.getBytes(); buf = data.getBytes();
_geomData = new GeomData; _geomData = new (std::nothrow) GeomData;
_geomData->offMeshConCount = 0; _geomData->offMeshConCount = 0;
unsigned char* src = buf; unsigned char* src = buf;

View File

@ -93,7 +93,7 @@ void NavMeshDebugDraw::depthMask(bool state)
void NavMeshDebugDraw::begin(duDebugDrawPrimitives prim, float size /*= 1.0f*/) void NavMeshDebugDraw::begin(duDebugDrawPrimitives prim, float size /*= 1.0f*/)
{ {
if (_currentPrimitive) return; if (_currentPrimitive) return;
_currentPrimitive = new Primitive; _currentPrimitive = new (std::nothrow) Primitive;
_currentPrimitive->type = getPrimitiveType(prim); _currentPrimitive->type = getPrimitiveType(prim);
_currentPrimitive->depthMask = _currentDepthMask; _currentPrimitive->depthMask = _currentDepthMask;
_currentPrimitive->start = _vertices.size(); _currentPrimitive->start = _vertices.size();

View File

@ -104,7 +104,7 @@ namespace cocos2d { namespace network {
} }
IDownloadTask *DownloaderApple::createCoTask(std::shared_ptr<const DownloadTask>& task) IDownloadTask *DownloaderApple::createCoTask(std::shared_ptr<const DownloadTask>& task)
{ {
DownloadTaskApple* coTask = new DownloadTaskApple(); DownloadTaskApple* coTask = new (std::nothrow) DownloadTaskApple();
DeclareDownloaderImplVar; DeclareDownloaderImplVar;
if (task->storagePath.length()) if (task->storagePath.length())
{ {

View File

@ -740,7 +740,7 @@ namespace cocos2d { namespace network {
IDownloadTask *DownloaderCURL::createCoTask(std::shared_ptr<const DownloadTask>& task) IDownloadTask *DownloaderCURL::createCoTask(std::shared_ptr<const DownloadTask>& task)
{ {
DownloadTaskCURL *coTask = new DownloadTaskCURL; DownloadTaskCURL *coTask = new (std::nothrow) DownloadTaskCURL;
coTask->init(task->storagePath, _impl->hints.tempFileNameSuffix); coTask->init(task->storagePath, _impl->hints.tempFileNameSuffix);
DLLOG(" DownloaderCURL: createTask: Id(%d)", coTask->serialId); DLLOG(" DownloaderCURL: createTask: Id(%d)", coTask->serialId);

View File

@ -130,7 +130,7 @@ namespace cocos2d { namespace network {
std::shared_ptr<const DownloadTask> Downloader::createDownloadDataTask(const std::string& srcUrl, const std::string& identifier/* = ""*/) std::shared_ptr<const DownloadTask> Downloader::createDownloadDataTask(const std::string& srcUrl, const std::string& identifier/* = ""*/)
{ {
DownloadTask *task_ = new DownloadTask(); DownloadTask *task_ = new (std::nothrow) DownloadTask();
std::shared_ptr<const DownloadTask> task(task_); std::shared_ptr<const DownloadTask> task(task_);
do do
{ {
@ -155,7 +155,7 @@ namespace cocos2d { namespace network {
const std::string& storagePath, const std::string& storagePath,
const std::string& identifier/* = ""*/) const std::string& identifier/* = ""*/)
{ {
DownloadTask *task_ = new DownloadTask(); DownloadTask *task_ = new (std::nothrow) DownloadTask();
std::shared_ptr<const DownloadTask> task(task_); std::shared_ptr<const DownloadTask> task(task_);
do do
{ {

View File

@ -78,7 +78,7 @@ namespace network {
static void processHttpResponse(HttpResponse* response, std::string& errorStr); static void processHttpResponse(HttpResponse* response, std::string& errorStr);
static HttpRequest *s_requestSentinel = new HttpRequest; static HttpRequest *s_requestSentinel = new (std::nothrow) HttpRequest;
// Worker thread // Worker thread
void HttpClient::networkThread() void HttpClient::networkThread()

View File

@ -308,10 +308,10 @@ SocketIOPacket * SocketIOPacket::createPacketWithType(std::string type, SocketIO
switch (version) switch (version)
{ {
case SocketIOPacket::SocketIOVersion::V09x: case SocketIOPacket::SocketIOVersion::V09x:
ret = new SocketIOPacket; ret = new (std::nothrow) SocketIOPacket;
break; break;
case SocketIOPacket::SocketIOVersion::V10x: case SocketIOPacket::SocketIOVersion::V10x:
ret = new SocketIOPacketV10x; ret = new (std::nothrow) SocketIOPacketV10x;
break; break;
} }
ret->initWithType(type); ret->initWithType(type);
@ -325,10 +325,10 @@ SocketIOPacket * SocketIOPacket::createPacketWithTypeIndex(int type, SocketIOPac
switch (version) switch (version)
{ {
case SocketIOPacket::SocketIOVersion::V09x: case SocketIOPacket::SocketIOVersion::V09x:
ret = new SocketIOPacket; ret = new (std::nothrow) SocketIOPacket;
break; break;
case SocketIOPacket::SocketIOVersion::V10x: case SocketIOPacket::SocketIOVersion::V10x:
return new SocketIOPacketV10x; return new (std::nothrow) SocketIOPacketV10x;
break; break;
} }
ret->initWithTypeIndex(type); ret->initWithTypeIndex(type);

View File

@ -120,8 +120,8 @@ WsThreadHelper::WsThreadHelper()
, _ws(nullptr) , _ws(nullptr)
, _needQuit(false) , _needQuit(false)
{ {
_UIWsMessageQueue = new std::list<WsMessage*>(); _UIWsMessageQueue = new (std::nothrow) std::list<WsMessage*>();
_subThreadWsMessageQueue = new std::list<WsMessage*>(); _subThreadWsMessageQueue = new (std::nothrow) std::list<WsMessage*>();
Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false); Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false);
} }
@ -140,7 +140,7 @@ bool WsThreadHelper::createThread(const WebSocket& ws)
_ws = const_cast<WebSocket*>(&ws); _ws = const_cast<WebSocket*>(&ws);
// Creates websocket thread // Creates websocket thread
_subThreadInstance = new std::thread(&WsThreadHelper::wsThreadEntryFunc, this); _subThreadInstance = new (std::nothrow) std::thread(&WsThreadHelper::wsThreadEntryFunc, this);
return true; return true;
} }
@ -309,7 +309,7 @@ bool WebSocket::init(const Delegate& delegate,
protocolCount = 1; protocolCount = 1;
} }
_wsProtocols = new libwebsocket_protocols[protocolCount+1]; _wsProtocols = new (std::nothrow) libwebsocket_protocols[protocolCount+1];
memset(_wsProtocols, 0, sizeof(libwebsocket_protocols)*(protocolCount+1)); memset(_wsProtocols, 0, sizeof(libwebsocket_protocols)*(protocolCount+1));
if (protocols && protocols->size() > 0) if (protocols && protocols->size() > 0)
@ -317,7 +317,7 @@ bool WebSocket::init(const Delegate& delegate,
int i = 0; int i = 0;
for (std::vector<std::string>::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i) for (std::vector<std::string>::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i)
{ {
char* name = new char[(*iter).length()+1]; char* name = new (std::nothrow) char[(*iter).length()+1];
strcpy(name, (*iter).c_str()); strcpy(name, (*iter).c_str());
_wsProtocols[i].name = name; _wsProtocols[i].name = name;
_wsProtocols[i].callback = WebSocketCallbackWrapper::onSocketCallback; _wsProtocols[i].callback = WebSocketCallbackWrapper::onSocketCallback;
@ -325,7 +325,7 @@ bool WebSocket::init(const Delegate& delegate,
} }
else else
{ {
char* name = new char[20]; char* name = new (std::nothrow) char[20];
strcpy(name, "default-protocol"); strcpy(name, "default-protocol");
_wsProtocols[0].name = name; _wsProtocols[0].name = name;
_wsProtocols[0].callback = WebSocketCallbackWrapper::onSocketCallback; _wsProtocols[0].callback = WebSocketCallbackWrapper::onSocketCallback;
@ -346,7 +346,7 @@ void WebSocket::send(const std::string& message)
WsMessage* msg = new (std::nothrow) WsMessage(); WsMessage* msg = new (std::nothrow) WsMessage();
msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_STRING; msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_STRING;
Data* data = new (std::nothrow) Data(); Data* data = new (std::nothrow) Data();
data->bytes = new char[message.length()+1]; data->bytes = new (std::nothrow) char[message.length()+1];
strcpy(data->bytes, message.c_str()); strcpy(data->bytes, message.c_str());
data->len = static_cast<ssize_t>(message.length()); data->len = static_cast<ssize_t>(message.length());
msg->obj = data; msg->obj = data;
@ -364,7 +364,7 @@ void WebSocket::send(const unsigned char* binaryMsg, unsigned int len)
WsMessage* msg = new (std::nothrow) WsMessage(); WsMessage* msg = new (std::nothrow) WsMessage();
msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_BINARY; msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_BINARY;
Data* data = new (std::nothrow) Data(); Data* data = new (std::nothrow) Data();
data->bytes = new char[len]; data->bytes = new (std::nothrow) char[len];
memcpy((void*)data->bytes, (void*)binaryMsg, len); memcpy((void*)data->bytes, (void*)binaryMsg, len);
data->len = len; data->len = len;
msg->obj = data; msg->obj = data;
@ -546,7 +546,7 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
//fixme: the log is not thread safe //fixme: the log is not thread safe
// CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", static_cast<int>(data->len), static_cast<int>(data->issued), static_cast<int>(remaining), static_cast<int>(n)); // CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", static_cast<int>(data->len), static_cast<int>(data->issued), static_cast<int>(remaining), static_cast<int>(n));
unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING]; unsigned char* buf = new (std::nothrow) unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING];
memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes + data->issued, n); memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes + data->issued, n);
@ -630,13 +630,13 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
// Accumulate the data (increasing the buffer as we go) // Accumulate the data (increasing the buffer as we go)
if (_currentDataLen == 0) if (_currentDataLen == 0)
{ {
_currentData = new char[len]; _currentData = new (std::nothrow) char[len];
memcpy (_currentData, in, len); memcpy (_currentData, in, len);
_currentDataLen = len; _currentDataLen = len;
} }
else else
{ {
char *new_data = new char [_currentDataLen + len]; char *new_data = new (std::nothrow) char [_currentDataLen + len];
memcpy (new_data, _currentData, _currentDataLen); memcpy (new_data, _currentData, _currentDataLen);
memcpy (new_data + _currentDataLen, in, len); memcpy (new_data + _currentDataLen, in, len);
CC_SAFE_DELETE_ARRAY(_currentData); CC_SAFE_DELETE_ARRAY(_currentData);
@ -663,12 +663,12 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
if (lws_frame_is_binary(wsi)) if (lws_frame_is_binary(wsi))
{ {
bytes = new char[_currentDataLen]; bytes = new (std::nothrow) char[_currentDataLen];
data->isBinary = true; data->isBinary = true;
} }
else else
{ {
bytes = new char[_currentDataLen+1]; bytes = new (std::nothrow) char[_currentDataLen+1];
bytes[_currentDataLen] = '\0'; bytes[_currentDataLen] = '\0';
data->isBinary = false; data->isBinary = false;
} }

View File

@ -271,7 +271,7 @@ void PhysicsShape::setSensor(bool sensor)
void PhysicsShape::recenterPoints(Vec2* points, int count, const Vec2& center) void PhysicsShape::recenterPoints(Vec2* points, int count, const Vec2& center)
{ {
cpVect* cpvs = new cpVect[count]; cpVect* cpvs = new (std::nothrow) cpVect[count];
cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count));
PhysicsHelper::cpvs2points(cpvs, points, count); PhysicsHelper::cpvs2points(cpvs, points, count);
delete[] cpvs; delete[] cpvs;
@ -287,7 +287,7 @@ void PhysicsShape::recenterPoints(Vec2* points, int count, const Vec2& center)
Vec2 PhysicsShape::getPolyonCenter(const Vec2* points, int count) Vec2 PhysicsShape::getPolyonCenter(const Vec2* points, int count)
{ {
cpVect* cpvs = new cpVect[count]; cpVect* cpvs = new (std::nothrow) cpVect[count];
cpVect center = cpCentroidForPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); cpVect center = cpCentroidForPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count));
delete[] cpvs; delete[] cpvs;
@ -550,7 +550,7 @@ bool PhysicsShapePolygon::init(const Vec2* points, int count, const PhysicsMater
{ {
_type = Type::POLYGEN; _type = Type::POLYGEN;
auto vecs = new cpVect[count]; auto vecs = new (std::nothrow) cpVect[count];
PhysicsHelper::points2cpvs(points, vecs, count); PhysicsHelper::points2cpvs(points, vecs, count);
auto shape = cpPolyShapeNew(s_sharedBody, count, vecs, PhysicsHelper::point2cpv(offset)); auto shape = cpPolyShapeNew(s_sharedBody, count, vecs, PhysicsHelper::point2cpv(offset));
CC_SAFE_DELETE_ARRAY(vecs); CC_SAFE_DELETE_ARRAY(vecs);
@ -573,7 +573,7 @@ bool PhysicsShapePolygon::init(const Vec2* points, int count, const PhysicsMater
float PhysicsShapePolygon::calculateArea(const Vec2* points, int count) float PhysicsShapePolygon::calculateArea(const Vec2* points, int count)
{ {
cpVect* vecs = new cpVect[count]; cpVect* vecs = new (std::nothrow) cpVect[count];
PhysicsHelper::points2cpvs(points, vecs, count); PhysicsHelper::points2cpvs(points, vecs, count);
float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs)); float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs));
CC_SAFE_DELETE_ARRAY(vecs); CC_SAFE_DELETE_ARRAY(vecs);
@ -583,7 +583,7 @@ float PhysicsShapePolygon::calculateArea(const Vec2* points, int count)
float PhysicsShapePolygon::calculateMoment(float mass, const Vec2* points, int count, const Vec2& offset) float PhysicsShapePolygon::calculateMoment(float mass, const Vec2* points, int count, const Vec2& offset)
{ {
cpVect* vecs = new cpVect[count]; cpVect* vecs = new (std::nothrow) cpVect[count];
PhysicsHelper::points2cpvs(points, vecs, count); PhysicsHelper::points2cpvs(points, vecs, count);
float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY
: PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset))); : PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset)));
@ -735,7 +735,7 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM
{ {
_type = Type::EDGEPOLYGEN; _type = Type::EDGEPOLYGEN;
vec = new cpVect[count]; vec = new (std::nothrow) cpVect[count];
PhysicsHelper::points2cpvs(points, vec, count); PhysicsHelper::points2cpvs(points, vec, count);
int i = 0; int i = 0;
@ -767,7 +767,7 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM
Vec2 PhysicsShapeEdgePolygon::getCenter() Vec2 PhysicsShapeEdgePolygon::getCenter()
{ {
int count = (int)_cpShapes.size(); int count = (int)_cpShapes.size();
cpVect* points = new cpVect[count]; cpVect* points = new (std::nothrow) cpVect[count];
int i = 0; int i = 0;
for(auto shape : _cpShapes) for(auto shape : _cpShapes)
{ {
@ -834,7 +834,7 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat
{ {
_type = Type::EDGECHAIN; _type = Type::EDGECHAIN;
vec = new cpVect[count]; vec = new (std::nothrow) cpVect[count];
PhysicsHelper::points2cpvs(points, vec, count); PhysicsHelper::points2cpvs(points, vec, count);
int i = 0; int i = 0;
@ -865,7 +865,7 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat
Vec2 PhysicsShapeEdgeChain::getCenter() Vec2 PhysicsShapeEdgeChain::getCenter()
{ {
int count = (int)_cpShapes.size() + 1; int count = (int)_cpShapes.size() + 1;
cpVect* points = new cpVect[count]; cpVect* points = new (std::nothrow) cpVect[count];
int i = 0; int i = 0;
for(auto shape : _cpShapes) for(auto shape : _cpShapes)
{ {

View File

@ -32,7 +32,7 @@ NS_CC_BEGIN
PhysicsSprite3D* PhysicsSprite3D::create(const std::string &modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics) PhysicsSprite3D* PhysicsSprite3D::create(const std::string &modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics)
{ {
auto ret = new PhysicsSprite3D(); auto ret = new (std::nothrow) PhysicsSprite3D();
if (ret && ret->initWithFile(modelPath)) if (ret && ret->initWithFile(modelPath))
{ {
auto obj = Physics3DRigidBody::create(rigidDes); auto obj = Physics3DRigidBody::create(rigidDes);

View File

@ -869,7 +869,7 @@ bool Image::encodeWithWIC(const std::string& filePath, bool isToRGB, GUID contai
{ {
bpp = 3; bpp = 3;
saveLen = _width * _height * bpp; saveLen = _width * _height * bpp;
pSaveData = new unsigned char[saveLen]; pSaveData = new (std::nothrow) unsigned char[saveLen];
int indL = 0, indR = 0; int indL = 0, indR = 0;
while (indL < saveLen && indR < _dataLen) while (indL < saveLen && indR < _dataLen)
@ -881,7 +881,7 @@ bool Image::encodeWithWIC(const std::string& filePath, bool isToRGB, GUID contai
} }
else else
{ {
pSaveData = new unsigned char[saveLen]; pSaveData = new (std::nothrow) unsigned char[saveLen];
memcpy(pSaveData, _data, saveLen); memcpy(pSaveData, _data, saveLen);
} }
@ -1456,7 +1456,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen)
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder"); CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
_unpack = true; _unpack = true;
_mipmaps[_numberOfMipmaps].len = width*height*4; _mipmaps[_numberOfMipmaps].len = width*height*4;
_mipmaps[_numberOfMipmaps].address = new unsigned char[width*height*4]; _mipmaps[_numberOfMipmaps].address = new (std::nothrow) unsigned char[width*height*4];
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[_numberOfMipmaps].address, true); PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[_numberOfMipmaps].address, true);
bpp = 2; bpp = 2;
} }
@ -1470,7 +1470,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen)
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder"); CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
_unpack = true; _unpack = true;
_mipmaps[_numberOfMipmaps].len = width*height*4; _mipmaps[_numberOfMipmaps].len = width*height*4;
_mipmaps[_numberOfMipmaps].address = new unsigned char[width*height*4]; _mipmaps[_numberOfMipmaps].address = new (std::nothrow) unsigned char[width*height*4];
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[_numberOfMipmaps].address, false); PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[_numberOfMipmaps].address, false);
bpp = 4; bpp = 4;
} }
@ -1612,7 +1612,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder"); CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
_unpack = true; _unpack = true;
_mipmaps[i].len = width*height*4; _mipmaps[i].len = width*height*4;
_mipmaps[i].address = new unsigned char[width*height*4]; _mipmaps[i].address = new (std::nothrow) unsigned char[width*height*4];
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[i].address, true); PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[i].address, true);
bpp = 2; bpp = 2;
} }
@ -1627,7 +1627,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder"); CCLOG("cocos2d: Hardware PVR decoder not present. Using software decoder");
_unpack = true; _unpack = true;
_mipmaps[i].len = width*height*4; _mipmaps[i].len = width*height*4;
_mipmaps[i].address = new unsigned char[width*height*4]; _mipmaps[i].address = new (std::nothrow) unsigned char[width*height*4];
PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[i].address, false); PVRTDecompressPVRTC(_data+dataOffset,width,height,_mipmaps[i].address, false);
bpp = 4; bpp = 4;
} }
@ -1643,7 +1643,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
unsigned int stride = width * bytePerPixel; unsigned int stride = width * bytePerPixel;
_unpack = true; _unpack = true;
_mipmaps[i].len = width*height*bytePerPixel; _mipmaps[i].len = width*height*bytePerPixel;
_mipmaps[i].address = new unsigned char[width*height*bytePerPixel]; _mipmaps[i].address = new (std::nothrow) unsigned char[width*height*bytePerPixel];
if (etc1_decode_image(static_cast<const unsigned char*>(_data+dataOffset), static_cast<etc1_byte*>(_mipmaps[i].address), width, height, bytePerPixel, stride) != 0) if (etc1_decode_image(static_cast<const unsigned char*>(_data+dataOffset), static_cast<etc1_byte*>(_mipmaps[i].address), width, height, bytePerPixel, stride) != 0)
{ {
return false; return false;

View File

@ -72,7 +72,7 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
- (id) init - (id) init
{ {
if( (self = [super init]) ) { if( (self = [super init]) ) {
_acceleration = new cocos2d::Acceleration(); _acceleration = new (std::nothrow) cocos2d::Acceleration();
_motionManager = [[CMMotionManager alloc] init]; _motionManager = [[CMMotionManager alloc] init];
_motionManager.accelerometerUpdateInterval = SENSOR_DELAY_GAME; _motionManager.accelerometerUpdateInterval = SENSOR_DELAY_GAME;
} }

View File

@ -65,7 +65,7 @@ bool cocos2d::Image::saveToFile(const std::string& filename, bool isToRGB)
// or want to save as jpg, remove the alpha channel. // or want to save as jpg, remove the alpha channel.
if (hasAlpha() && bitsPerPixel == 24) if (hasAlpha() && bitsPerPixel == 24)
{ {
pixels = new unsigned char[myDataLength]; pixels = new (std::nothrow) unsigned char[myDataLength];
for (int i = 0; i < _height; ++i) for (int i = 0; i < _height; ++i)
{ {

View File

@ -237,43 +237,43 @@ void GLProgramCache::loadDefaultGLPrograms()
loadDefaultGLProgram(p, kShaderType_3DSkinPositionTex); loadDefaultGLProgram(p, kShaderType_3DSkinPositionTex);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_TEXTURE, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_TEXTURE, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DPositionNormal); loadDefaultGLProgram(p, kShaderType_3DPositionNormal);
_programs.insert( std::make_pair(GLProgram::SHADER_3D_POSITION_NORMAL, p) ); _programs.insert( std::make_pair(GLProgram::SHADER_3D_POSITION_NORMAL, p) );
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DPositionNormalTex); loadDefaultGLProgram(p, kShaderType_3DPositionNormalTex);
_programs.insert( std::make_pair(GLProgram::SHADER_3D_POSITION_NORMAL_TEXTURE, p) ); _programs.insert( std::make_pair(GLProgram::SHADER_3D_POSITION_NORMAL_TEXTURE, p) );
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DSkinPositionNormalTex); loadDefaultGLProgram(p, kShaderType_3DSkinPositionNormalTex);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_NORMAL_TEXTURE, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_NORMAL_TEXTURE, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DPositionBumpedNormalTex); loadDefaultGLProgram(p, kShaderType_3DPositionBumpedNormalTex);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_POSITION_BUMPEDNORMAL_TEXTURE, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_POSITION_BUMPEDNORMAL_TEXTURE, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DSkinPositionBumpedNormalTex); loadDefaultGLProgram(p, kShaderType_3DSkinPositionBumpedNormalTex);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_BUMPEDNORMAL_TEXTURE, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_BUMPEDNORMAL_TEXTURE, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DParticleColor); loadDefaultGLProgram(p, kShaderType_3DParticleColor);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_PARTICLE_COLOR, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_PARTICLE_COLOR, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DParticleTex); loadDefaultGLProgram(p, kShaderType_3DParticleTex);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_PARTICLE_TEXTURE, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_PARTICLE_TEXTURE, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DSkyBox); loadDefaultGLProgram(p, kShaderType_3DSkyBox);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKYBOX, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_SKYBOX, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_3DTerrain); loadDefaultGLProgram(p, kShaderType_3DTerrain);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_TERRAIN, p)); _programs.insert(std::make_pair(GLProgram::SHADER_3D_TERRAIN, p));
p = new GLProgram(); p = new (std::nothrow) GLProgram();
loadDefaultGLProgram(p, kShaderType_CameraClear); loadDefaultGLProgram(p, kShaderType_CameraClear);
_programs.insert(std::make_pair(GLProgram::SHADER_CAMERA_CLEAR, p)); _programs.insert(std::make_pair(GLProgram::SHADER_CAMERA_CLEAR, p));
} }

View File

@ -155,7 +155,7 @@ void UniformValue::setCallback(const std::function<void(GLProgram*, Uniform*)> &
if (_type == Type::CALLBACK_FN) if (_type == Type::CALLBACK_FN)
delete _value.callback; delete _value.callback;
_value.callback = new std::function<void(GLProgram*, Uniform*)>(); _value.callback = new (std::nothrow) std::function<void(GLProgram*, Uniform*)>();
*_value.callback = callback; *_value.callback = callback;
_type = Type::CALLBACK_FN; _type = Type::CALLBACK_FN;
@ -290,7 +290,7 @@ void VertexAttribValue::apply()
void VertexAttribValue::setCallback(const std::function<void(VertexAttrib*)> &callback) void VertexAttribValue::setCallback(const std::function<void(VertexAttrib*)> &callback)
{ {
_value.callback = new std::function<void(VertexAttrib*)>(); _value.callback = new (std::nothrow) std::function<void(VertexAttrib*)>();
*_value.callback = callback; *_value.callback = callback;
_useCallback = true; _useCallback = true;
_enabled = true; _enabled = true;

View File

@ -1392,7 +1392,7 @@ void Texture2D::addSpriteFrameCapInset(SpriteFrame* spritframe, const Rect& capI
{ {
if(nullptr == _ninePatchInfo) if(nullptr == _ninePatchInfo)
{ {
_ninePatchInfo = new NinePatchInfo; _ninePatchInfo = new (std::nothrow) NinePatchInfo;
} }
if(nullptr == spritframe) if(nullptr == spritframe)
{ {

View File

@ -154,7 +154,7 @@ void TextureCache::addImageAsync(const std::string &path, const std::function<vo
if (_loadingThread == nullptr) if (_loadingThread == nullptr)
{ {
// create a new thread to load images // create a new thread to load images
_loadingThread = new std::thread(&TextureCache::loadImage, this); _loadingThread = new (std::nothrow) std::thread(&TextureCache::loadImage, this);
_needQuit = false; _needQuit = false;
} }
@ -617,7 +617,7 @@ void TextureCache::renameTextureWithKey(const std::string srcName, const std::st
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(dstName); std::string fullpath = FileUtils::getInstance()->fullPathForFilename(dstName);
Texture2D* tex = it->second; Texture2D* tex = it->second;
Image* image = new Image(); Image* image = new (std::nothrow) Image();
if (image) if (image)
{ {
bool ret = image->initWithImageFile(dstName); bool ret = image->initWithImageFile(dstName);

View File

@ -68,7 +68,7 @@ unsigned char* getImageData(Image* img, Texture2D::PixelFormat& ePixFmt)
{ {
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB" // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
inPixel32 = (unsigned int*)img->getData(); inPixel32 = (unsigned int*)img->getData();
pTmpData = new unsigned char[nWidth * nHeight * 2]; pTmpData = new (std::nothrow) unsigned char[nWidth * nHeight * 2];
outPixel16 = (unsigned short*)pTmpData; outPixel16 = (unsigned short*)pTmpData;
for (unsigned int i = 0; i < uLen; ++i, ++inPixel32) for (unsigned int i = 0; i < uLen; ++i, ++inPixel32)
@ -82,7 +82,7 @@ unsigned char* getImageData(Image* img, Texture2D::PixelFormat& ePixFmt)
else else
{ {
// Convert "RRRRRRRRGGGGGGGGBBBBBBBB" to "RRRRRGGGGGGBBBBB" // Convert "RRRRRRRRGGGGGGGGBBBBBBBB" to "RRRRRGGGGGGBBBBB"
pTmpData = new unsigned char[nWidth * nHeight * 2]; pTmpData = new (std::nothrow) unsigned char[nWidth * nHeight * 2];
outPixel16 = (unsigned short*)pTmpData; outPixel16 = (unsigned short*)pTmpData;
inPixel8 = (unsigned char*)img->getData(); inPixel8 = (unsigned char*)img->getData();
@ -105,7 +105,7 @@ unsigned char* getImageData(Image* img, Texture2D::PixelFormat& ePixFmt)
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB" // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB"
inPixel32 = (unsigned int*)img->getData(); inPixel32 = (unsigned int*)img->getData();
pTmpData = new unsigned char[nWidth * nHeight * 3]; pTmpData = new (std::nothrow) unsigned char[nWidth * nHeight * 3];
unsigned char* outPixel8 = pTmpData; unsigned char* outPixel8 = pTmpData;
for (unsigned int i = 0; i < uLen; ++i, ++inPixel32) for (unsigned int i = 0; i < uLen; ++i, ++inPixel32)

View File

@ -79,7 +79,7 @@ static bool js_cocos2dx_Sprite3D_createAsync(JSContext *cx, uint32_t argc, jsval
}; };
callback = lambda; callback = lambda;
JSB_HeapValueWrapper* data = new JSB_HeapValueWrapper(cx, args.get(argc == 4 ? 3 : 4)); JSB_HeapValueWrapper* data = new (std::nothrow) JSB_HeapValueWrapper(cx, args.get(argc == 4 ? 3 : 4));
if(argc == 4) if(argc == 4)
cocos2d::Sprite3D::createAsync(modelPath, callback, data); cocos2d::Sprite3D::createAsync(modelPath, callback, data);

View File

@ -454,7 +454,7 @@ ScriptingCore* ScriptingCore::getInstance()
{ {
static ScriptingCore* instance = nullptr; static ScriptingCore* instance = nullptr;
if (instance == nullptr) if (instance == nullptr)
instance = new ScriptingCore(); instance = new (std::nothrow) ScriptingCore();
return instance; return instance;
} }
@ -475,7 +475,7 @@ ScriptingCore::ScriptingCore()
void ScriptingCore::initRegister() void ScriptingCore::initRegister()
{ {
this->addRegisterCallback(registerDefaultClasses); this->addRegisterCallback(registerDefaultClasses);
this->_runLoop = new SimpleRunLoop(); this->_runLoop = new (std::nothrow) SimpleRunLoop();
} }
void ScriptingCore::string_report(JS::HandleValue val) { void ScriptingCore::string_report(JS::HandleValue val) {

View File

@ -38,7 +38,7 @@ void static freeSpaceChildren(cpSpace *space);
template<class T> template<class T>
static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
TypeTest<T> t; TypeTest<T> t;
T* cobj = new T(); T* cobj = new (std::nothrow) T();
cobj->autorelease(); cobj->autorelease();
js_type_class_t *p; js_type_class_t *p;
std::string typeName = t.s_name(); std::string typeName = t.s_name();
@ -483,7 +483,7 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, ui
bool JSPROXY_CCPhysicsSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) { bool JSPROXY_CCPhysicsSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true; bool ok = true;
PhysicsSprite* cobj = new PhysicsSprite(); PhysicsSprite* cobj = new (std::nothrow) PhysicsSprite();
cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj); cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj);
if (_ccobj) { if (_ccobj) {
_ccobj->autorelease(); _ccobj->autorelease();
@ -511,7 +511,7 @@ static bool JSPROXY_CCPhysicsSprite_ctor(JSContext *cx, uint32_t argc, jsval *vp
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
PhysicsSprite *nobj = new PhysicsSprite(); PhysicsSprite *nobj = new (std::nothrow) PhysicsSprite();
if (nobj) { if (nobj) {
nobj->autorelease(); nobj->autorelease();
} }
@ -951,7 +951,7 @@ void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis)
static static
bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, JS::HandleObject jsspace, cpSpace *space, unsigned int is_oo) bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, JS::HandleObject jsspace, cpSpace *space, unsigned int is_oo)
{ {
struct collision_handler *handler = new collision_handler(); struct collision_handler *handler = new (std::nothrow) collision_handler();
handler->typeA = 0; handler->typeA = 0;
handler->typeB = 0; handler->typeB = 0;
@ -1048,7 +1048,7 @@ bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval
struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis);
cpSpace* space = (cpSpace*) proxy->handle; cpSpace* space = (cpSpace*) proxy->handle;
collision_handler *handler = new collision_handler(); collision_handler *handler = new (std::nothrow) collision_handler();
JSB_PRECONDITION(handler, "Error allocating memory"); JSB_PRECONDITION(handler, "Error allocating memory");
handler->typeA = 0; handler->typeA = 0;
@ -1367,7 +1367,7 @@ bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){
ok &= jsval_to_uint( cx, args.get(3), (unsigned int*)&group ); ok &= jsval_to_uint( cx, args.get(3), (unsigned int*)&group );
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
cpSegmentQueryInfo *out = new cpSegmentQueryInfo(); cpSegmentQueryInfo *out = new (std::nothrow) cpSegmentQueryInfo();
cpShape* target = cpSpaceSegmentQueryFirst(space, start, end, layers, group, out); cpShape* target = cpSpaceSegmentQueryFirst(space, start, end, layers, group, out);
if(target) if(target)
@ -1405,7 +1405,7 @@ bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *v
ok &= jsval_to_uint( cx, args.get(3), (unsigned int*)&group ); ok &= jsval_to_uint( cx, args.get(3), (unsigned int*)&group );
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo(); cpNearestPointQueryInfo* info = new (std::nothrow) cpNearestPointQueryInfo();
cpShape* target = cpSpaceNearestPointQueryNearest(space, point, maxDistance, layers, group, info); cpShape* target = cpSpaceNearestPointQueryNearest(space, point, maxDistance, layers, group, info);
if(target) if(target)

View File

@ -537,7 +537,7 @@ bool js_cocos2dx_JSTouchDelegate_registerStandardDelegate(JSContext *cx, uint32_
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JSTouchDelegate *touch = new JSTouchDelegate(); JSTouchDelegate *touch = new (std::nothrow) JSTouchDelegate();
int priority = 1; int priority = 1;
if (argc == 2) if (argc == 2)
@ -562,7 +562,7 @@ bool js_cocos2dx_JSTouchDelegate_registerTargetedDelegate(JSContext *cx, uint32_
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JSTouchDelegate *touch = new JSTouchDelegate(); JSTouchDelegate *touch = new (std::nothrow) JSTouchDelegate();
touch->registerTargetedDelegate(args.get(0).toInt32(), args.get(1).toBoolean()); touch->registerTargetedDelegate(args.get(0).toInt32(), args.get(1).toBoolean());
JS::RootedObject jsobj(cx, args.get(2).toObjectOrNull()); JS::RootedObject jsobj(cx, args.get(2).toObjectOrNull());
@ -807,7 +807,7 @@ void JSScheduleWrapper::setTargetForSchedule(JS::HandleValue sched, JSScheduleWr
JSObject* jsfunc = sched.toObjectOrNull(); JSObject* jsfunc = sched.toObjectOrNull();
auto targetArray = getTargetForSchedule(sched); auto targetArray = getTargetForSchedule(sched);
if (NULL == targetArray) { if (NULL == targetArray) {
targetArray = new __Array(); targetArray = new (std::nothrow) __Array();
targetArray->init(); targetArray->init();
schedFunc_proxy_t *p = (schedFunc_proxy_t *)malloc(sizeof(schedFunc_proxy_t)); schedFunc_proxy_t *p = (schedFunc_proxy_t *)malloc(sizeof(schedFunc_proxy_t));
assert(p); assert(p);
@ -834,7 +834,7 @@ void JSScheduleWrapper::setTargetForJSObject(JS::HandleObject jsTargetObj, JSSch
{ {
auto targetArray = getTargetForJSObject(jsTargetObj); auto targetArray = getTargetForJSObject(jsTargetObj);
if (NULL == targetArray) { if (NULL == targetArray) {
targetArray = new __Array(); targetArray = new (std::nothrow) __Array();
targetArray->init(); targetArray->init();
schedTarget_proxy_t *p = (schedTarget_proxy_t *)malloc(sizeof(schedTarget_proxy_t)); schedTarget_proxy_t *p = (schedTarget_proxy_t *)malloc(sizeof(schedTarget_proxy_t));
assert(p); assert(p);
@ -1255,7 +1255,7 @@ bool js_CCNode_scheduleOnce(JSContext *cx, uint32_t argc, jsval *vp)
if (!bFound) if (!bFound)
{ {
tmpCobj = new JSScheduleWrapper(); tmpCobj = new (std::nothrow) JSScheduleWrapper();
tmpCobj->autorelease(); tmpCobj->autorelease();
tmpCobj->setJSCallbackThis(thisValue); tmpCobj->setJSCallbackThis(thisValue);
tmpCobj->setJSCallbackFunc(args.get(0)); tmpCobj->setJSCallbackFunc(args.get(0));
@ -1351,7 +1351,7 @@ bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp)
if (!bFound) if (!bFound)
{ {
tmpCobj = new JSScheduleWrapper(); tmpCobj = new (std::nothrow) JSScheduleWrapper();
tmpCobj->autorelease(); tmpCobj->autorelease();
tmpCobj->setJSCallbackThis(thisValue); tmpCobj->setJSCallbackThis(thisValue);
tmpCobj->setJSCallbackFunc(args.get(0)); tmpCobj->setJSCallbackFunc(args.get(0));
@ -1425,7 +1425,7 @@ bool js_cocos2dx_CCNode_scheduleUpdateWithPriority(JSContext *cx, uint32_t argc,
if (!bFound) if (!bFound)
{ {
tmpCobj = new JSScheduleWrapper(); tmpCobj = new (std::nothrow) JSScheduleWrapper();
tmpCobj->autorelease(); tmpCobj->autorelease();
tmpCobj->setJSCallbackThis(thisValue); tmpCobj->setJSCallbackThis(thisValue);
tmpCobj->setJSCallbackFunc(jsUpdateFunc); tmpCobj->setJSCallbackFunc(jsUpdateFunc);
@ -1526,7 +1526,7 @@ bool js_cocos2dx_CCNode_scheduleUpdate(JSContext *cx, uint32_t argc, jsval *vp)
if (!bFound) if (!bFound)
{ {
tmpCobj = new JSScheduleWrapper(); tmpCobj = new (std::nothrow) JSScheduleWrapper();
tmpCobj->autorelease(); tmpCobj->autorelease();
tmpCobj->setJSCallbackThis(thisValue); tmpCobj->setJSCallbackThis(thisValue);
tmpCobj->setJSCallbackFunc(jsUpdateFunc); tmpCobj->setJSCallbackFunc(jsUpdateFunc);
@ -1641,7 +1641,7 @@ bool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval
if (!bFound) if (!bFound)
{ {
tmpCObj = new JSScheduleWrapper(); tmpCObj = new (std::nothrow) JSScheduleWrapper();
tmpCObj->autorelease(); tmpCObj->autorelease();
tmpCObj->setJSCallbackThis(args.get(0)); tmpCObj->setJSCallbackThis(args.get(0));
tmpCObj->setJSCallbackFunc(jsUpdateFunc); tmpCObj->setJSCallbackFunc(jsUpdateFunc);
@ -1767,7 +1767,7 @@ bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsva
if (!bFound) if (!bFound)
{ {
tmpCObj = new JSScheduleWrapper(); tmpCObj = new (std::nothrow) JSScheduleWrapper();
tmpCObj->autorelease(); tmpCObj->autorelease();
tmpCObj->setJSCallbackThis(args.get(0)); tmpCObj->setJSCallbackThis(args.get(0));
tmpCObj->setJSCallbackFunc(args.get(1)); tmpCObj->setJSCallbackFunc(args.get(1));
@ -5643,7 +5643,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
std::string arg0; std::string arg0;
ok &= jsval_to_std_string(cx, args.get(0), &arg0); ok &= jsval_to_std_string(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0)); cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0));
jsval jsret = JSVAL_NULL; jsval jsret = JSVAL_NULL;
if (ret) { if (ret) {
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret)); jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
@ -5657,7 +5657,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
ok &= jsval_to_std_string(cx, args.get(0), &arg0); ok &= jsval_to_std_string(cx, args.get(0), &arg0);
ok &= jsval_to_ccrect(cx, args.get(1), &arg1); ok &= jsval_to_ccrect(cx, args.get(1), &arg1);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1)); cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1));
jsval jsret = JSVAL_NULL; jsval jsret = JSVAL_NULL;
if (ret) { if (ret) {
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret)); jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
@ -5673,7 +5673,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
ok &= jsval_to_ccrect(cx, args.get(1), &arg1); ok &= jsval_to_ccrect(cx, args.get(1), &arg1);
ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2)); cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2));
jsval jsret = JSVAL_NULL; jsval jsret = JSVAL_NULL;
if (ret) { if (ret) {
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret)); jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
@ -5691,7 +5691,7 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2);
ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3)); cocos2d::PolygonInfo* ret = new (std::nothrow) cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3));
jsval jsret = JSVAL_NULL; jsval jsret = JSVAL_NULL;
if (ret) { if (ret) {
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret)); jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));

View File

@ -270,7 +270,7 @@ public:
static __JSPlistDelegator* getInstance() { static __JSPlistDelegator* getInstance() {
static __JSPlistDelegator* pInstance = NULL; static __JSPlistDelegator* pInstance = NULL;
if (pInstance == NULL) { if (pInstance == NULL) {
pInstance = new __JSPlistDelegator(); pInstance = new (std::nothrow) __JSPlistDelegator();
} }
return pInstance; return pInstance;
}; };

View File

@ -64,7 +64,7 @@ void CCBScriptCallbackProxy::onNodeLoaded(Node * pNode,
NodeLoader * pNodeLoader) {} NodeLoader * pNodeLoader) {}
CCBSelectorResolver * CCBScriptCallbackProxy::createNew() { CCBSelectorResolver * CCBScriptCallbackProxy::createNew() {
CCBScriptCallbackProxy * ret = new CCBScriptCallbackProxy(); CCBScriptCallbackProxy * ret = new (std::nothrow) CCBScriptCallbackProxy();
ret->setJSOwner(this->owner); ret->setJSOwner(this->owner);
return dynamic_cast<CCBSelectorResolver *>(ret); return dynamic_cast<CCBSelectorResolver *>(ret);
} }
@ -99,7 +99,7 @@ bool js_cocos2dx_CCBAnimationManager_animationCompleteCallback(JSContext *cx, ui
js_proxy_t *p = jsb_get_js_proxy(obj); js_proxy_t *p = jsb_get_js_proxy(obj);
cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(p ? p->ptr : NULL); cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(p ? p->ptr : NULL);
JSCCBAnimationWrapper *tmpCobj = new JSCCBAnimationWrapper(); JSCCBAnimationWrapper *tmpCobj = new (std::nothrow) JSCCBAnimationWrapper();
tmpCobj->autorelease(); tmpCobj->autorelease();
tmpCobj->setJSCallbackThis(args.get(0)); tmpCobj->setJSCallbackThis(args.get(0));
@ -289,7 +289,7 @@ bool js_CocosBuilder_create(JSContext *cx, uint32_t argc, jsval *vp)
ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader()); ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader());
CCBReader * ret = new CCBReader(ccNodeLoaderLibrary); CCBReader * ret = new (std::nothrow) CCBReader(ccNodeLoaderLibrary);
ret->autorelease(); ret->autorelease();
jsval jsret; jsval jsret;

View File

@ -115,7 +115,7 @@ static bool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx
return true; return true;
} }
else if (argc == 1 || argc == 2) { else if (argc == 1 || argc == 2) {
JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
tmpObj->autorelease(); tmpObj->autorelease();
cocos2d::__Dictionary* dict = static_cast<cocos2d::__Dictionary*>(cobj->getUserObject()); cocos2d::__Dictionary* dict = static_cast<cocos2d::__Dictionary*>(cobj->getUserObject());
@ -161,7 +161,7 @@ static bool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, u
return true; return true;
} }
else if (argc == 1 || argc == 2) { else if (argc == 1 || argc == 2) {
JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
tmpObj->autorelease(); tmpObj->autorelease();
cocos2d::__Dictionary* dict = static_cast<cocos2d::__Dictionary*>(cobj->getUserObject()); cocos2d::__Dictionary* dict = static_cast<cocos2d::__Dictionary*>(cobj->getUserObject());
@ -202,7 +202,7 @@ static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
if (argc == 3) { if (argc == 3) {
JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
tmpObj->autorelease(); tmpObj->autorelease();
tmpObj->setJSCallbackFunc(args.get(1)); tmpObj->setJSCallbackFunc(args.get(1));
@ -217,7 +217,7 @@ static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32
} }
if(argc == 5){ if(argc == 5){
JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); JSArmatureWrapper *tmpObj = new (std::nothrow) JSArmatureWrapper();
tmpObj->autorelease(); tmpObj->autorelease();
tmpObj->setJSCallbackFunc(args.get(3)); tmpObj->setJSCallbackFunc(args.get(3));

View File

@ -73,7 +73,7 @@ ComponentJS::ComponentJS(const std::string& scriptFileName)
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
mozilla::Maybe<JS::PersistentRootedObject> *jsObj = new mozilla::Maybe<JS::PersistentRootedObject>(); mozilla::Maybe<JS::PersistentRootedObject> *jsObj = new (std::nothrow) mozilla::Maybe<JS::PersistentRootedObject>();
JS::RootedObject proto(cx, protoValue.toObjectOrNull()); JS::RootedObject proto(cx, protoValue.toObjectOrNull());
JS::RootedObject parent(cx, typeClass->proto.ref()); JS::RootedObject parent(cx, typeClass->proto.ref());

View File

@ -86,7 +86,7 @@ static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, j
{ {
// save the delegate // save the delegate
JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull()); JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull());
JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); JSB_ScrollViewDelegate* nativeDelegate = new (std::nothrow) JSB_ScrollViewDelegate();
nativeDelegate->setJSDelegate(jsDelegate); nativeDelegate->setJSDelegate(jsDelegate);
cobj->setUserObject(nativeDelegate); cobj->setUserObject(nativeDelegate);
@ -196,13 +196,13 @@ static bool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, js
{ {
// save the delegate // save the delegate
JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull()); JS::RootedObject jsDelegate(cx, args.get(0).toObjectOrNull());
JSB_TableViewDelegate* nativeDelegate = new JSB_TableViewDelegate(); JSB_TableViewDelegate* nativeDelegate = new (std::nothrow) JSB_TableViewDelegate();
nativeDelegate->setJSDelegate(jsDelegate); nativeDelegate->setJSDelegate(jsDelegate);
__Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject());
if (NULL == userDict) if (NULL == userDict)
{ {
userDict = new __Dictionary(); userDict = new (std::nothrow) __Dictionary();
cobj->setUserObject(userDict); cobj->setUserObject(userDict);
userDict->release(); userDict->release();
} }
@ -376,14 +376,14 @@ static bool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc,
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
if (argc == 1) if (argc == 1)
{ {
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource();
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
pNativeSource->setTableViewDataSource(jsdata); pNativeSource->setTableViewDataSource(jsdata);
__Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject());
if (NULL == userDict) if (NULL == userDict)
{ {
userDict = new __Dictionary(); userDict = new (std::nothrow) __Dictionary();
cobj->setUserObject(userDict); cobj->setUserObject(userDict);
userDict->release(); userDict->release();
} }
@ -409,14 +409,14 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *
if (argc == 3 || argc == 2) if (argc == 3 || argc == 2)
{ {
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource();
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
pNativeSource->setTableViewDataSource(jsdata); pNativeSource->setTableViewDataSource(jsdata);
cocos2d::Size arg1; cocos2d::Size arg1;
ok &= jsval_to_ccsize(cx, args.get(1), &arg1); ok &= jsval_to_ccsize(cx, args.get(1), &arg1);
cocos2d::extension::TableView* ret = NULL; cocos2d::extension::TableView* ret = NULL;
ret = new TableView(); ret = new (std::nothrow) TableView();
ret->autorelease(); ret->autorelease();
ret->setDataSource(pNativeSource); ret->setDataSource(pNativeSource);
@ -454,7 +454,7 @@ static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *
} }
ret->reloadData(); ret->reloadData();
__Dictionary* userDict = new __Dictionary(); __Dictionary* userDict = new (std::nothrow) __Dictionary();
userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE);
ret->setUserObject(userDict); ret->setUserObject(userDict);
userDict->release(); userDict->release();
@ -480,7 +480,7 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp
if (argc == 3 || argc == 2) if (argc == 3 || argc == 2)
{ {
JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource();
JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull());
pNativeSource->setTableViewDataSource(jsdata); pNativeSource->setTableViewDataSource(jsdata);
cobj->setDataSource(pNativeSource); cobj->setDataSource(pNativeSource);
@ -507,7 +507,7 @@ static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp
} }
cobj->reloadData(); cobj->reloadData();
__Dictionary* userDict = new __Dictionary(); __Dictionary* userDict = new (std::nothrow) __Dictionary();
userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE);
cobj->setUserObject(userDict); cobj->setUserObject(userDict);
userDict->release(); userDict->release();
@ -583,7 +583,7 @@ public:
CC_SAFE_DELETE(_callback); CC_SAFE_DELETE(_callback);
} }
JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JSContext* cx = ScriptingCore::getInstance()->getGlobalContext();
_callback = new JSFunctionWrapper(cx, jsTarget, jsFunc); _callback = new (std::nothrow) JSFunctionWrapper(cx, jsTarget, jsFunc);
_jsFunc.ref() = jsFunc.toObjectOrNull(); _jsFunc.ref() = jsFunc.toObjectOrNull();
} }
@ -631,7 +631,7 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext
} }
// save the delegate // save the delegate
JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget(); JSB_ControlButtonTarget* nativeDelegate = new (std::nothrow) JSB_ControlButtonTarget();
JS::RootedObject jscb(cx, jsDelegate); JS::RootedObject jscb(cx, jsDelegate);
nativeDelegate->setJSCallback(args.get(1), jscb); nativeDelegate->setJSCallback(args.get(1), jscb);
@ -640,7 +640,7 @@ static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext
__Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject()); __Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject());
if (nullptr == nativeDelegateArray) if (nullptr == nativeDelegateArray)
{ {
nativeDelegateArray = new __Array(); nativeDelegateArray = new (std::nothrow) __Array();
nativeDelegateArray->init(); nativeDelegateArray->init();
cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2 cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2
nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1 nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1

View File

@ -70,7 +70,7 @@ bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp)
{ {
if (argc == 0) { if (argc == 0) {
cocos2d::GLNode* cobj = new cocos2d::GLNode(); cocos2d::GLNode* cobj = new (std::nothrow) cocos2d::GLNode();
cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj); cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj);
if (_ccobj) { if (_ccobj) {
_ccobj->autorelease(); _ccobj->autorelease();
@ -108,7 +108,7 @@ static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
cocos2d::GLNode *nobj = new cocos2d::GLNode(); cocos2d::GLNode *nobj = new (std::nothrow) cocos2d::GLNode();
js_proxy_t* p = jsb_new_proxy(nobj, obj); js_proxy_t* p = jsb_new_proxy(nobj, obj);
nobj->autorelease(); nobj->autorelease();
JS::AddNamedObjectRoot(cx, &p->obj, "GLNode"); JS::AddNamedObjectRoot(cx, &p->obj, "GLNode");
@ -119,7 +119,7 @@ static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp)
bool js_cocos2dx_GLNode_create(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_GLNode_create(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
cocos2d::GLNode* ret = new cocos2d::GLNode(); cocos2d::GLNode* ret = new (std::nothrow) cocos2d::GLNode();
jsval jsret; jsval jsret;
do { do {
if (ret) { if (ret) {

View File

@ -937,7 +937,7 @@ bool jsval_to_ccarray_of_CCPoint(JSContext* cx, JS::HandleValue v, Point **point
uint32_t len; uint32_t len;
JS_GetArrayLength(cx, jsobj, &len); JS_GetArrayLength(cx, jsobj, &len);
Point *array = new Point[len]; Point *array = new (std::nothrow) Point[len];
for( uint32_t i=0; i< len;i++ ) { for( uint32_t i=0; i< len;i++ ) {
JS::RootedValue valarg(cx); JS::RootedValue valarg(cx);

View File

@ -194,7 +194,7 @@ bool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp)
GLsizei length; GLsizei length;
glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length); glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length);
GLchar* src = new GLchar[length]; GLchar* src = new (std::nothrow) GLchar[length];
glGetProgramInfoLog(arg0, length, NULL, src); glGetProgramInfoLog(arg0, length, NULL, src);
args.rval().set(charptr_to_jsval(cx, src)); args.rval().set(charptr_to_jsval(cx, src));
@ -215,7 +215,7 @@ bool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp)
GLsizei length; GLsizei length;
glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length); glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length);
GLchar* src = new GLchar[length]; GLchar* src = new (std::nothrow) GLchar[length];
glGetShaderInfoLog(arg0, length, NULL, src); glGetShaderInfoLog(arg0, length, NULL, src);
args.rval().set(charptr_to_jsval(cx, src)); args.rval().set(charptr_to_jsval(cx, src));
@ -236,7 +236,7 @@ bool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp)
GLsizei length; GLsizei length;
glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length); glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length);
GLchar* src = new GLchar[length]; GLchar* src = new (std::nothrow) GLchar[length];
glGetShaderSource(arg0, length, NULL, src); glGetShaderSource(arg0, length, NULL, src);
args.rval().set(charptr_to_jsval(cx, src)); args.rval().set(charptr_to_jsval(cx, src));
@ -262,7 +262,7 @@ bool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp)
GLsizei length; GLsizei length;
glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length);
GLchar* buffer = new GLchar[length]; GLchar* buffer = new (std::nothrow) GLchar[length];
GLint size = -1; GLint size = -1;
GLenum type = -1; GLenum type = -1;
@ -306,7 +306,7 @@ bool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp)
GLsizei length; GLsizei length;
glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length);
GLchar* buffer = new GLchar[length]; GLchar* buffer = new (std::nothrow) GLchar[length];
GLint size = -1; GLint size = -1;
GLenum type = -1; GLenum type = -1;
@ -344,7 +344,7 @@ bool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp)
GLsizei length; GLsizei length;
glGetProgramiv(arg0, GL_ATTACHED_SHADERS, &length); glGetProgramiv(arg0, GL_ATTACHED_SHADERS, &length);
GLuint* buffer = new GLuint[length]; GLuint* buffer = new (std::nothrow) GLuint[length];
memset(buffer, 0, length * sizeof(GLuint)); memset(buffer, 0, length * sizeof(GLuint));
//Fix bug 2448, it seems that glGetAttachedShaders will crash if we send NULL to the third parameter (eg Windows), same as in lua binding //Fix bug 2448, it seems that glGetAttachedShaders will crash if we send NULL to the third parameter (eg Windows), same as in lua binding
GLsizei realShaderCount = 0; GLsizei realShaderCount = 0;
@ -376,7 +376,7 @@ bool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp)
// copy, to be able to add '\0' // copy, to be able to add '\0'
size_t len = strlen((char*)extensions); size_t len = strlen((char*)extensions);
GLubyte* copy = new GLubyte[len+1]; GLubyte* copy = new (std::nothrow) GLubyte[len+1];
strncpy((char*)copy, (const char*)extensions, len ); strncpy((char*)copy, (const char*)extensions, len );
int start_extension=0; int start_extension=0;
@ -438,7 +438,7 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
GLsizei length; GLsizei length;
glGetProgramiv(arg0, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length); glGetProgramiv(arg0, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length);
GLchar* namebuffer = new GLchar[length+1]; GLchar* namebuffer = new (std::nothrow) GLchar[length+1];
GLint size = -1; GLint size = -1;
GLenum type = -1; GLenum type = -1;
@ -520,7 +520,7 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
// FIXME: glew on windows will cause array overflow after invoking glGetUniformfv. // FIXME: glew on windows will cause array overflow after invoking glGetUniformfv.
// It seems that glGetUniformfv re-assign the memeroy with a wrong size which is 4x than we pass in. // It seems that glGetUniformfv re-assign the memeroy with a wrong size which is 4x than we pass in.
// For temporary solution, we allocate 4x array. // For temporary solution, we allocate 4x array.
GLfloat* param = new GLfloat[usize*4]; GLfloat* param = new (std::nothrow) GLfloat[usize*4];
glGetUniformfv(arg0, arg1, param); glGetUniformfv(arg0, arg1, param);
typedArray = JS_NewFloat32Array(cx, usize); typedArray = JS_NewFloat32Array(cx, usize);
@ -531,7 +531,7 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
// FIXME: glew on windows will cause array overflow after invoking glGetUniformfv. // FIXME: glew on windows will cause array overflow after invoking glGetUniformfv.
// It seems that glGetUniformfv re-assign the memeroy with a wrong size which is 4x than we pass in. // It seems that glGetUniformfv re-assign the memeroy with a wrong size which is 4x than we pass in.
// For temporary solution, we allocate 4x array. // For temporary solution, we allocate 4x array.
GLint* param = new GLint[usize*4]; GLint* param = new (std::nothrow) GLint[usize*4];
glGetUniformiv(arg0, arg1, param); glGetUniformiv(arg0, arg1, param);
typedArray = JS_NewInt32Array(cx, usize); typedArray = JS_NewInt32Array(cx, usize);

View File

@ -44,7 +44,7 @@ void MinXmlHttpRequest::_gotHeader(string header)
{ {
// Get Header and Set StatusText // Get Header and Set StatusText
// Split String into Tokens // Split String into Tokens
char * cstr = new char [header.length()+1]; char * cstr = new (std::nothrow) char [header.length()+1];
// check for colon. // check for colon.
size_t found_header_field = header.find_first_of(":"); size_t found_header_field = header.find_first_of(":");
@ -335,7 +335,7 @@ JS_BINDED_CLASS_GLUE_IMPL(MinXmlHttpRequest);
JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
MinXmlHttpRequest* req = new MinXmlHttpRequest(); MinXmlHttpRequest* req = new (std::nothrow) MinXmlHttpRequest();
req->autorelease(); req->autorelease();
js_proxy_t *p; js_proxy_t *p;

View File

@ -153,7 +153,7 @@ bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp)
JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); JSB_PRECONDITION2( ok, cx, false, "Error processing arguments");
} while (0); } while (0);
JSB_SocketIODelegate* siodelegate = new JSB_SocketIODelegate(); JSB_SocketIODelegate* siodelegate = new (std::nothrow) JSB_SocketIODelegate();
CCLOG("Calling native SocketIO.connect method"); CCLOG("Calling native SocketIO.connect method");
SIOClient* ret = SocketIO::connect(url, *siodelegate); SIOClient* ret = SocketIO::connect(url, *siodelegate);

View File

@ -268,8 +268,8 @@ bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, j
JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, proto, JS::NullPtr())); JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, proto, JS::NullPtr()));
//JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, js_cocos2dx_websocket_class, args)); //JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, js_cocos2dx_websocket_class, args));
WebSocket* cobj = new WebSocket(); WebSocket* cobj = new (std::nothrow) WebSocket();
JSB_WebSocketDelegate* delegate = new JSB_WebSocketDelegate(); JSB_WebSocketDelegate* delegate = new (std::nothrow) JSB_WebSocketDelegate();
delegate->setJSDelegate(obj); delegate->setJSDelegate(obj);
if (argc == 2) if (argc == 2)

View File

@ -206,7 +206,7 @@ void JavaScriptObjCBridge::CallInfo::pushValue(void *val){
else if ([oval isKindOfClass:[NSString class]]) else if ([oval isKindOfClass:[NSString class]])
{ {
const char *content = [oval cStringUsingEncoding:NSUTF8StringEncoding]; const char *content = [oval cStringUsingEncoding:NSUTF8StringEncoding];
m_ret.stringValue = new string(content); m_ret.stringValue = new (std::nothrow) string(content);
m_returnType = TypeString; m_returnType = TypeString;
} }
else if ([oval isKindOfClass:[NSDictionary class]]) else if ([oval isKindOfClass:[NSDictionary class]])
@ -232,7 +232,7 @@ JS_BINDED_CLASS_GLUE_IMPL(JavaScriptObjCBridge);
*/ */
JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge) JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge)
{ {
JavaScriptObjCBridge* jsj = new JavaScriptObjCBridge(); JavaScriptObjCBridge* jsj = new (std::nothrow) JavaScriptObjCBridge();
js_proxy_t *p; js_proxy_t *p;
jsval out; jsval out;

View File

@ -184,7 +184,7 @@ static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsva
if (argc == 1) if (argc == 1)
{ {
// save the delegate // save the delegate
JSB_EditBoxDelegate* nativeDelegate = new JSB_EditBoxDelegate(); JSB_EditBoxDelegate* nativeDelegate = new (std::nothrow) JSB_EditBoxDelegate();
nativeDelegate->setJSDelegate(args.get(0)); nativeDelegate->setJSDelegate(args.get(0));
cobj->setUserObject(nativeDelegate); cobj->setUserObject(nativeDelegate);

View File

@ -977,7 +977,7 @@ int lua_cocos2dx_3d_AABB_constructor(lua_State* L)
ok &= luaval_to_vec3(L, 3, &arg1, "cc.AABB:AABB"); ok &= luaval_to_vec3(L, 3, &arg1, "cc.AABB:AABB");
if (!ok) { break; } if (!ok) { break; }
cobj = new cocos2d::AABB(arg0, arg1); cobj = new (std::nothrow) cocos2d::AABB(arg0, arg1);
tolua_pushusertype(L,(void*)cobj,"cc.AABB"); tolua_pushusertype(L,(void*)cobj,"cc.AABB");
tolua_register_gc(L,lua_gettop(L)); tolua_register_gc(L,lua_gettop(L));
return 1; return 1;
@ -986,7 +986,7 @@ int lua_cocos2dx_3d_AABB_constructor(lua_State* L)
ok = true; ok = true;
do{ do{
if (argc == 0) { if (argc == 0) {
cobj = new cocos2d::AABB(); cobj = new (std::nothrow) cocos2d::AABB();
tolua_pushusertype(L,(void*)cobj,"cc.AABB"); tolua_pushusertype(L,(void*)cobj,"cc.AABB");
tolua_register_gc(L,lua_gettop(L)); tolua_register_gc(L,lua_gettop(L));
return 1; return 1;
@ -1381,7 +1381,7 @@ int lua_cocos2dx_3d_OBB_constructor(lua_State* L)
ok &= luaval_to_object<cocos2d::AABB>(L, 2, "cc.AABB",&arg0, "cc.OBB:OBB"); ok &= luaval_to_object<cocos2d::AABB>(L, 2, "cc.AABB",&arg0, "cc.OBB:OBB");
if (!ok) { break; } if (!ok) { break; }
cobj = new cocos2d::OBB(*arg0); cobj = new (std::nothrow) cocos2d::OBB(*arg0);
tolua_pushusertype(L,(void*)cobj,"cc.OBB"); tolua_pushusertype(L,(void*)cobj,"cc.OBB");
tolua_register_gc(L,lua_gettop(L)); tolua_register_gc(L,lua_gettop(L));
return 1; return 1;
@ -1390,7 +1390,7 @@ int lua_cocos2dx_3d_OBB_constructor(lua_State* L)
ok = true; ok = true;
do{ do{
if (argc == 0) { if (argc == 0) {
cobj = new cocos2d::OBB(); cobj = new (std::nothrow) cocos2d::OBB();
tolua_pushusertype(L,(void*)cobj,"cc.OBB"); tolua_pushusertype(L,(void*)cobj,"cc.OBB");
tolua_register_gc(L,lua_gettop(L)); tolua_register_gc(L,lua_gettop(L));
return 1; return 1;
@ -1407,7 +1407,7 @@ int lua_cocos2dx_3d_OBB_constructor(lua_State* L)
ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.OBB:OBB"); ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.OBB:OBB");
if (!ok) { break; } if (!ok) { break; }
cobj = new cocos2d::OBB(arg0, arg1); cobj = new (std::nothrow) cocos2d::OBB(arg0, arg1);
tolua_pushusertype(L,(void*)cobj,"cc.OBB"); tolua_pushusertype(L,(void*)cobj,"cc.OBB");
tolua_register_gc(L,lua_gettop(L)); tolua_register_gc(L,lua_gettop(L));
return 1; return 1;
@ -1839,7 +1839,7 @@ int lua_cocos2dx_3d_OBB_getCorners(lua_State* L)
return 0; return 0;
} }
arg0 = new cocos2d::Vec3[len]; arg0 = new (std::nothrow) cocos2d::Vec3[len];
if (nullptr == arg0) if (nullptr == arg0)
{ {
@ -2075,7 +2075,7 @@ int lua_cocos2dx_3d_Ray_constructor(lua_State* L)
ok &= luaval_to_vec3(L, 3, &arg1, "cc.Ray:Ray"); ok &= luaval_to_vec3(L, 3, &arg1, "cc.Ray:Ray");
if (!ok) { break; } if (!ok) { break; }
cobj = new cocos2d::Ray(arg0, arg1); cobj = new (std::nothrow) cocos2d::Ray(arg0, arg1);
tolua_pushusertype(L,(void*)cobj,"cc.Ray"); tolua_pushusertype(L,(void*)cobj,"cc.Ray");
tolua_register_gc(L,lua_gettop(L)); tolua_register_gc(L,lua_gettop(L));
return 1; return 1;
@ -2084,7 +2084,7 @@ int lua_cocos2dx_3d_Ray_constructor(lua_State* L)
ok = true; ok = true;
do{ do{
if (argc == 0) { if (argc == 0) {
cobj = new cocos2d::Ray(); cobj = new (std::nothrow) cocos2d::Ray();
tolua_pushusertype(L,(void*)cobj,"cc.Ray"); tolua_pushusertype(L,(void*)cobj,"cc.Ray");
tolua_register_gc(L,lua_gettop(L)); tolua_register_gc(L,lua_gettop(L));
return 1; return 1;

View File

@ -557,7 +557,7 @@ static int tolua_Cocos2d_glBufferData00(lua_State* tolua_S)
{ {
unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0);
long length = (long)tolua_tonumber(tolua_S,2,0); long length = (long)tolua_tonumber(tolua_S,2,0);
float* floatArray = new float[length]; float* floatArray = new (std::nothrow) float[length];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -600,7 +600,7 @@ static int tolua_Cocos2d_glBufferSubData00(lua_State* tolua_S)
unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0);
long offset = (long)tolua_tonumber(tolua_S,2,0); long offset = (long)tolua_tonumber(tolua_S,2,0);
long length = (long)tolua_tonumber(tolua_S,3,0); long length = (long)tolua_tonumber(tolua_S,3,0);
float* floatArray = new float[length]; float* floatArray = new (std::nothrow) float[length];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -850,7 +850,7 @@ static int tolua_Cocos2d_glCompressedTexImage2D00(lua_State* tolua_S)
int imageSize = (int)tolua_tonumber(tolua_S, 7, 0); int imageSize = (int)tolua_tonumber(tolua_S, 7, 0);
long length = (long)tolua_tonumber(tolua_S,8,0); long length = (long)tolua_tonumber(tolua_S,8,0);
float* floatArray = new float[length]; float* floatArray = new (std::nothrow) float[length];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -905,7 +905,7 @@ static int tolua_Cocos2d_glCompressedTexSubImage2D00(lua_State* tolua_S)
int imageSize = (int)tolua_tonumber(tolua_S, 8, 0); int imageSize = (int)tolua_tonumber(tolua_S, 8, 0);
long length = (long)tolua_tonumber(tolua_S,9,0); long length = (long)tolua_tonumber(tolua_S,9,0);
float* floatArray = new float[length]; float* floatArray = new (std::nothrow) float[length];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -1459,7 +1459,7 @@ static int tolua_Cocos2d_glDrawElements00(lua_State* tolua_S)
{ {
if (arg3 > 0) if (arg3 > 0)
{ {
unsigned char* unit8Array = new unsigned char[arg3]; unsigned char* unit8Array = new (std::nothrow) unsigned char[arg3];
if (NULL == unit8Array) if (NULL == unit8Array)
{ {
return 0; return 0;
@ -1481,7 +1481,7 @@ static int tolua_Cocos2d_glDrawElements00(lua_State* tolua_S)
{ {
if (arg3 > 0) if (arg3 > 0)
{ {
unsigned short* shortArray = new unsigned short[arg3]; unsigned short* shortArray = new (std::nothrow) unsigned short[arg3];
if (NULL == shortArray) if (NULL == shortArray)
{ {
return 0; return 0;
@ -1504,8 +1504,8 @@ static int tolua_Cocos2d_glDrawElements00(lua_State* tolua_S)
{ {
if (arg3 > 0) if (arg3 > 0)
{ {
unsigned int* intArray = new unsigned int[arg3]; unsigned int* intArray = new (std::nothrow) unsigned int[arg3];
if (NULL == intArray) if (nullptr == intArray)
{ {
return 0; return 0;
} }
@ -2723,7 +2723,7 @@ static int tolua_Cocos2d_glReadPixels00(lua_State* tolua_S)
unsigned int arg5 = (unsigned int)tolua_tonumber(tolua_S, 6, 0); unsigned int arg5 = (unsigned int)tolua_tonumber(tolua_S, 6, 0);
long length = (long)tolua_tonumber(tolua_S,7,0); long length = (long)tolua_tonumber(tolua_S,7,0);
unsigned char* unit8Array = new unsigned char[length]; unsigned char* unit8Array = new (std::nothrow) unsigned char[length];
if (NULL == unit8Array) if (NULL == unit8Array)
{ {
return 0; return 0;
@ -3110,7 +3110,7 @@ static int tolua_Cocos2d_glTexImage2D00(lua_State* tolua_S)
unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0); unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0);
unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0); unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0);
unsigned char* unit8Array = new unsigned char[arg8]; unsigned char* unit8Array = new (std::nothrow) unsigned char[arg8];
if (NULL == unit8Array) if (NULL == unit8Array)
{ {
return 0; return 0;
@ -3236,7 +3236,7 @@ static int tolua_Cocos2d_glTexSubImage2D00(lua_State* tolua_S)
unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0); unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0);
unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0); unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0);
unsigned char* unit8Array = new unsigned char[arg8]; unsigned char* unit8Array = new (std::nothrow) unsigned char[arg8];
if (NULL == unit8Array) if (NULL == unit8Array)
{ {
return 0; return 0;
@ -3316,7 +3316,7 @@ static int tolua_Cocos2d_glUniform1fv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
float* floatArray = new float[arg2]; float* floatArray = new (std::nothrow) float[arg2];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -3385,7 +3385,7 @@ static int tolua_Cocos2d_glUniform1iv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
int* intArray = new int[arg2]; int* intArray = new (std::nothrow) int[arg2];
if (NULL == intArray) if (NULL == intArray)
{ {
return 0; return 0;
@ -3456,7 +3456,7 @@ static int tolua_Cocos2d_glUniform2fv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
float* floatArray = new float[arg2]; float* floatArray = new (std::nothrow) float[arg2];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -3527,7 +3527,7 @@ static int tolua_Cocos2d_glUniform2iv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
int* intArray = new int[arg2]; int* intArray = new (std::nothrow) int[arg2];
if (NULL == intArray) if (NULL == intArray)
{ {
return 0; return 0;
@ -3600,7 +3600,7 @@ static int tolua_Cocos2d_glUniform3fv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
float* floatArray = new float[arg2]; float* floatArray = new (std::nothrow) float[arg2];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -3673,7 +3673,7 @@ static int tolua_Cocos2d_glUniform3iv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
int* intArray = new int[arg2]; int* intArray = new (std::nothrow) int[arg2];
if (NULL == intArray) if (NULL == intArray)
{ {
return 0; return 0;
@ -3748,7 +3748,7 @@ static int tolua_Cocos2d_glUniform4fv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
float* floatArray = new float[arg2]; float* floatArray = new (std::nothrow) float[arg2];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -3823,7 +3823,7 @@ static int tolua_Cocos2d_glUniform4iv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
int* intArray = new int[arg2]; int* intArray = new (std::nothrow) int[arg2];
if (NULL == intArray) if (NULL == intArray)
{ {
return 0; return 0;
@ -3864,7 +3864,7 @@ static int tolua_Cocos2d_glUniformMatrix2fv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0); unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
float* floatArray = new float[arg2]; float* floatArray = new (std::nothrow) float[arg2];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -3905,7 +3905,7 @@ static int tolua_Cocos2d_glUniformMatrix3fv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0); unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
float* floatArray = new float[arg2]; float* floatArray = new (std::nothrow) float[arg2];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -3948,7 +3948,7 @@ static int tolua_Cocos2d_glUniformMatrix4fv00(lua_State* tolua_S)
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
bool arg1 = (bool)tolua_toboolean(tolua_S, 2, 0); bool arg1 = (bool)tolua_toboolean(tolua_S, 2, 0);
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
float* floatArray = new float[arg2]; float* floatArray = new (std::nothrow) float[arg2];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -4069,7 +4069,7 @@ static int tolua_Cocos2d_glVertexAttrib1fv00(lua_State* tolua_S)
{ {
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
float* floatArray = new float[arg1]; float* floatArray = new (std::nothrow) float[arg1];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -4141,7 +4141,7 @@ static int tolua_Cocos2d_glVertexAttrib2fv00(lua_State* tolua_S)
{ {
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
float* floatArray = new float[arg1]; float* floatArray = new (std::nothrow) float[arg1];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -4215,7 +4215,7 @@ static int tolua_Cocos2d_glVertexAttrib3fv00(lua_State* tolua_S)
{ {
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
float* floatArray = new float[arg1]; float* floatArray = new (std::nothrow) float[arg1];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -4291,7 +4291,7 @@ static int tolua_Cocos2d_glVertexAttrib4fv00(lua_State* tolua_S)
{ {
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
float* floatArray = new float[arg1]; float* floatArray = new (std::nothrow) float[arg1];
if (NULL == floatArray) if (NULL == floatArray)
{ {
return 0; return 0;
@ -4459,7 +4459,7 @@ CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2d_DrawPrimitives_drawPoints00(lua
if (numberOfPoints > 0) if (numberOfPoints > 0)
{ {
cocos2d::Vec2* points = new cocos2d::Vec2[numberOfPoints]; cocos2d::Vec2* points = new (std::nothrow) cocos2d::Vec2[numberOfPoints];
if (NULL == points) if (NULL == points)
return 0; return 0;
@ -4621,7 +4621,7 @@ CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2d_DrawPrimitives_drawPoly00(lua_S
if (numOfVertices > 0) if (numOfVertices > 0)
{ {
cocos2d::Vec2* points = new cocos2d::Vec2[numOfVertices]; cocos2d::Vec2* points = new (std::nothrow) cocos2d::Vec2[numOfVertices];
if (NULL == points) if (NULL == points)
return 0; return 0;
@ -4675,7 +4675,7 @@ CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2d_DrawPrimitives_drawSolidPoly00(
unsigned int numberOfPoints = ((unsigned int) tolua_tonumber(tolua_S,2,0)); unsigned int numberOfPoints = ((unsigned int) tolua_tonumber(tolua_S,2,0));
if (numberOfPoints > 0) if (numberOfPoints > 0)
{ {
cocos2d::Vec2* points = new cocos2d::Vec2[numberOfPoints]; cocos2d::Vec2* points = new (std::nothrow) cocos2d::Vec2[numberOfPoints];
if (NULL == points) if (NULL == points)
return 0; return 0;

View File

@ -2767,7 +2767,7 @@ static int lua_cocos2dx_LabelBMFont_constructor(lua_State* tolua_S)
{ {
if(!ok) if(!ok)
return 0; return 0;
cobj = new cocos2d::LabelBMFont(); cobj = new (std::nothrow) cocos2d::LabelBMFont();
cobj->autorelease(); cobj->autorelease();
int ID = (int)cobj->_ID ; int ID = (int)cobj->_ID ;
int* luaID = &cobj->_luaID ; int* luaID = &cobj->_luaID ;
@ -4287,7 +4287,7 @@ static int lua_cocos2dx_LabelTTF_constructor(lua_State* tolua_S)
{ {
if(!ok) if(!ok)
return 0; return 0;
cobj = new cocos2d::LabelTTF(); cobj = new (std::nothrow) cocos2d::LabelTTF();
cobj->autorelease(); cobj->autorelease();
int ID = (int)cobj->_ID ; int ID = (int)cobj->_ID ;
int* luaID = &cobj->_luaID ; int* luaID = &cobj->_luaID ;

Some files were not shown because too many files have changed in this diff Show More