issue #2271: Fixing some memory leaks.

This commit is contained in:
James Chen 2013-06-10 11:43:43 +08:00
parent 5092755e73
commit a14df8d28d
8 changed files with 15 additions and 15 deletions

View File

@ -39,13 +39,12 @@ class CCArmatureDataManager : public CCObject
{
public:
static CCArmatureDataManager *sharedArmatureDataManager();
static void purgeArmatureSystem();
private:
CCArmatureDataManager(void);
~CCArmatureDataManager(void);
public:
virtual void purgeArmatureSystem();
/**
* Init CCArmatureDataManager
*/

View File

@ -222,7 +222,6 @@ void WsThreadHelper::update(float dt)
enum WS_MSG {
WS_MSG_TO_SUBTRHEAD_SENDING_STRING = 0,
WS_MSG_TO_SUBTRHEAD_SENDING_BINARY,
WS_MSG_TO_SUBTRHEAD_CLOSING,
WS_MSG_TO_UITHREAD_OPEN,
WS_MSG_TO_UITHREAD_MESSAGE,
WS_MSG_TO_UITHREAD_ERROR,
@ -381,10 +380,6 @@ void WebSocket::close()
CCLOG("websocket (%p) connection closed by client", this);
_readyState = kStateClosed;
WsMessage* msg = new WsMessage();
msg->what = WS_MSG_TO_SUBTRHEAD_CLOSING;
_wsHelper->sendMessageToSubThread(msg);
_wsHelper->joinSubThread();
// onClose callback needs to be invoked at the end of this method
@ -481,21 +476,27 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
case LWS_CALLBACK_PROTOCOL_DESTROY:
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
{
WsMessage* msg = new WsMessage();
WsMessage* msg = NULL;
if (reason == LWS_CALLBACK_CLIENT_CONNECTION_ERROR
|| (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == kStateConnecting)
|| (reason == LWS_CALLBACK_DEL_POLL_FD && _readyState == kStateConnecting)
)
{
msg = new WsMessage();
msg->what = WS_MSG_TO_UITHREAD_ERROR;
_readyState = kStateClosing;
}
else if (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == kStateClosing)
{
msg = new WsMessage();
msg->what = WS_MSG_TO_UITHREAD_CLOSE;
}
if (msg)
{
_wsHelper->sendMessageToUIThread(msg);
}
}
break;
case LWS_CALLBACK_CLIENT_ESTABLISHED:
{

View File

@ -15,7 +15,7 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
// SimpleAudioEngine::end();
cocos2d::extension::CCArmatureDataManager::sharedArmatureDataManager()->purgeArmatureSystem();
cocos2d::extension::CCArmatureDataManager::purgeArmatureSystem();
}
bool AppDelegate::applicationDidFinishLaunching()

View File

@ -23,7 +23,7 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
CCScriptEngineManager::sharedManager()->purgeSharedManager();
CCScriptEngineManager::purgeSharedManager();
}
bool AppDelegate::applicationDidFinishLaunching()

View File

@ -19,7 +19,7 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
CCScriptEngineManager::sharedManager()->purgeSharedManager();
CCScriptEngineManager::purgeSharedManager();
}
bool AppDelegate::applicationDidFinishLaunching()

View File

@ -15,7 +15,7 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
CCScriptEngineManager::sharedManager()->purgeSharedManager();
CCScriptEngineManager::purgeSharedManager();
}
bool AppDelegate::applicationDidFinishLaunching()

View File

@ -23,7 +23,7 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
CCScriptEngineManager::sharedManager()->purgeSharedManager();
CCScriptEngineManager::purgeSharedManager();
}
bool AppDelegate::applicationDidFinishLaunching()

View File

@ -21,7 +21,7 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
CCScriptEngineManager::sharedManager()->purgeSharedManager();
CCScriptEngineManager::purgeSharedManager();
}
bool AppDelegate::applicationDidFinishLaunching()