I’m subclassing CCControlButton and need to check background sprites during init, which was crashing because the m_backgroundSpriteDispatchTable had not been setup yet. I added a line to check if it has and return NULL if not.
CCScale9Sprite* CCControlButton::getBackgroundSpriteForState(CCControlState state)
{
if (m_backgroundSpriteDispatchTable == NULL) return NULL; // if called before init is completed
CCScale9Sprite* backgroundSprite = (CCScale9Sprite*)m_backgroundSpriteDispatchTable->objectForKey(state);
if (backgroundSprite)
{
return backgroundSprite;
}
return (CCScale9Sprite*)m_backgroundSpriteDispatchTable->objectForKey(CCControlStateNormal);
}
Please add to the source.