issue #61, add retain for member variable

This commit is contained in:
Walzer 2010-09-04 10:06:26 +00:00
parent 41d9386ad3
commit 4226dcede9
12 changed files with 71 additions and 22 deletions

View File

@ -221,4 +221,14 @@ CCTexture2D * CCAtlasNode::getTexture()
return m_pTextureAtlas->getTexture();
}
void CCAtlasNode::setTextureAtlas(CCTextureAtlas* var)
{
m_pTextureAtlas = var;
CCX_SAFE_RETAIN(m_pTextureAtlas);
}
CCTextureAtlas * CCAtlasNode::getTextureAtlas()
{
return m_pTextureAtlas;
}
} // namespace cocos2d

View File

@ -252,17 +252,9 @@ CCGridBase* CCNode::getGrid()
/// grid setter
void CCNode::setGrid(CCGridBase* pGrid)
{
if(m_pGrid)
{
m_pGrid->release();
}
CCX_SAFE_RELEASE(m_pGrid);
m_pGrid = pGrid;
if(m_pGrid)
{
m_pGrid->retain();
}
CCX_SAFE_RETAIN(m_pGrid);
}

View File

@ -62,7 +62,7 @@ protected:
ccColor3B m_tColorUnmodified;
CCTextureAtlas * m_pTextureAtlas;
CCX_PROPERTY(CCTextureAtlas*, m_pTextureAtlas, TextureAtlas);
// protocol variables
CCX_PROPERTY(bool, m_bIsOpacityModifyRGB, IsOpacityModifyRGB)

View File

@ -69,7 +69,7 @@ namespace cocos2d {
/** pointer to the map of tiles */
CCX_SYNTHESIZE(unsigned int*, m_pTiles, Tiles);
/** Tilset information for the layer */
CCX_SYNTHESIZE(CCTMXTilesetInfo*, m_pTileSet, TileSet);
CCX_PROPERTY(CCTMXTilesetInfo*, m_pTileSet, TileSet);
/** Layer orientation, which is the same as the map orientation */
CCX_SYNTHESIZE(int, m_nLayerOrientation, LayerOrientation);
/** properties from the layer. They can be added using Tiled */

View File

@ -106,7 +106,7 @@ namespace cocos2d {
/** map orientation */
CCX_SYNTHESIZE(int, m_nMapOrientation, MapOrientation);
/** object groups */
CCX_SYNTHESIZE(NSMutableArray<CCTMXObjectGroup*>*, m_pObjectGroups, ObjectGroups);
CCX_PROPERTY(NSMutableArray<CCTMXObjectGroup*>*, m_pObjectGroups, ObjectGroups);
/** properties */
CCX_SYNTHESIZE(StringToStringDictionary*, m_pProperties, Properties);
public:

View File

@ -128,11 +128,11 @@ namespace cocos2d {
// tiles width & height
CCX_SYNTHESIZE(CGSize, m_tTileSize, TileSize);
// Layers
CCX_SYNTHESIZE(NSMutableArray<CCTMXLayerInfo*>*, m_pLayers, Layers);
CCX_PROPERTY(NSMutableArray<CCTMXLayerInfo*>*, m_pLayers, Layers);
// tilesets
CCX_SYNTHESIZE(NSMutableArray<CCTMXTilesetInfo*>*, m_pTilesets, Tilesets);
CCX_PROPERTY(NSMutableArray<CCTMXTilesetInfo*>*, m_pTilesets, Tilesets);
// ObjectGroups
CCX_SYNTHESIZE(NSMutableArray<CCTMXObjectGroup*>*, m_pObjectGroups, ObjectGroups);
CCX_PROPERTY(NSMutableArray<CCTMXObjectGroup*>*, m_pObjectGroups, ObjectGroups);
// parent element
CCX_SYNTHESIZE(int, m_nParentElement, ParentElement);
// parent GID

View File

@ -114,8 +114,8 @@ namespace cocos2d{
void CCMenuItemLabel::setLabel(CCNode* var)
{
CCX_SAFE_RELEASE(m_pLabel);
var->retain();
m_pLabel = var;
CCX_SAFE_RETAIN(m_pLabel);
this->setContentSize(m_pLabel->getContentSize());
}
CCMenuItemLabel * CCMenuItemLabel::itemWithLabel(CCNode*label, SelectorProtocol* target, SEL_MunuHandler selector)
@ -301,6 +301,7 @@ namespace cocos2d{
void CCMenuItemSprite::setNormalImage(CCNode* var)
{
m_pNormalImage = var;
CCX_SAFE_RETAIN(m_pNormalImage);
}
CCNode * CCMenuItemSprite::getSelectedImage()
{
@ -309,6 +310,7 @@ namespace cocos2d{
void CCMenuItemSprite::setSelectedImage(CCNode* var)
{
m_pSelectedImage = var;
CCX_SAFE_RETAIN(m_pSelectedImage);
}
CCNode * CCMenuItemSprite::getDisabledImage()
{
@ -317,6 +319,7 @@ namespace cocos2d{
void CCMenuItemSprite::setDisabledImage(CCNode* var)
{
m_pDisabledImage = var;
CCX_SAFE_RETAIN(m_pDisabledImage);
}
CCMenuItemSprite * CCMenuItemSprite::itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite)
{
@ -454,6 +457,7 @@ namespace cocos2d{
void CCMenuItemToggle::setSubItems(NSMutableArray<CCMenuItem*>* var)
{
m_pSubItems = var;
CCX_SAFE_RETAIN(m_pSubItems);
}
NSMutableArray<CCMenuItem*> *CCMenuItemToggle::getSubItems()
{

View File

@ -284,8 +284,8 @@ namespace cocos2d {
void CCRibbon::setTexture(CCTexture2D* var)
{
m_pTexture->release();
var->retain();
m_pTexture = var;
CCX_SAFE_RETAIN(m_pTexture);
this->setContentSize(m_pTexture->getContentSize());
/* XXX Don't update blending function in Ribbons */
}

View File

@ -616,8 +616,8 @@ namespace cocos2d {
void CCParticleSystem::setTexture(CCTexture2D* var)
{
CCX_SAFE_RELEASE(m_pTexture)
var->retain();
m_pTexture = var;
CCX_SAFE_RETAIN(m_pTexture);
// If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it
if( m_pTexture && ! m_pTexture->getHasPremultipliedAlpha() &&

View File

@ -131,6 +131,15 @@ namespace cocos2d {
m_pTiles = NULL;
}
}
CCTMXTilesetInfo * CCTMXLayer::getTileSet()
{
return m_pTileSet;
}
void CCTMXLayer::setTileSet(CCTMXTilesetInfo* var)
{
m_pTileSet = var;
CCX_SAFE_RETAIN(m_pTileSet);
}
void CCTMXLayer::releaseMap()
{
if( m_pTiles )

View File

@ -54,7 +54,7 @@ namespace cocos2d{
m_tTileSize = mapInfo->getTileSize();
m_nMapOrientation = mapInfo->getOrientation();
m_pObjectGroups = mapInfo->getObjectGroups();
m_pObjectGroups->retain();
CCX_SAFE_RETAIN(m_pObjectGroups);
m_pProperties = mapInfo->getProperties();
m_pTileProperties = mapInfo->getTileProperties();
@ -119,7 +119,15 @@ namespace cocos2d{
m_pTileProperties = NULL;
}
}
NSMutableArray<CCTMXObjectGroup*> * CCTMXTiledMap::getObjectGroups()
{
return m_pObjectGroups;
}
void CCTMXTiledMap::setObjectGroups(NSMutableArray<CCTMXObjectGroup*>* var)
{
m_pObjectGroups = var;
CCX_SAFE_RETAIN(m_pObjectGroups);
}
// private
CCTMXLayer * CCTMXTiledMap::parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo)
{

View File

@ -157,7 +157,33 @@ namespace cocos2d {
m_pTileProperties = NULL;
}
}
NSMutableArray<CCTMXLayerInfo*> * CCTMXMapInfo::getLayers()
{
return m_pLayers;
}
void CCTMXMapInfo::setLayers(NSMutableArray<CCTMXLayerInfo*>* var)
{
m_pLayers = var;
CCX_SAFE_RETAIN(m_pLayers);
}
NSMutableArray<CCTMXTilesetInfo*> * CCTMXMapInfo::getTilesets()
{
return m_pTilesets;
}
void CCTMXMapInfo::setTilesets(NSMutableArray<CCTMXTilesetInfo*>* var)
{
m_pTilesets = var;
CCX_SAFE_RETAIN(m_pTilesets);
}
NSMutableArray<CCTMXObjectGroup*> * CCTMXMapInfo::getObjectGroups()
{
return m_pObjectGroups;
}
void CCTMXMapInfo::setObjectGroups(NSMutableArray<CCTMXObjectGroup*>* var)
{
m_pObjectGroups = var;
CCX_SAFE_RETAIN(m_pObjectGroups);
}
bool CCTMXMapInfo::parseXMLFile(const char *xmlFilename)
{
FILE *fp = NULL;