mirror of https://github.com/axmolengine/axmol.git
fix crash when back to parent test case
This commit is contained in:
parent
04f52d0e21
commit
b2a592ce36
|
@ -268,7 +268,8 @@ WebSocketCloseTest::WebSocketCloseTest()
|
||||||
|
|
||||||
if (!_wsiTest->init(*this, "ws://echo.websocket.org"))
|
if (!_wsiTest->init(*this, "ws://echo.websocket.org"))
|
||||||
{
|
{
|
||||||
CC_SAFE_DELETE(_wsiTest);
|
delete _wsiTest;
|
||||||
|
_wsiTest = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, [](Ref* sender){
|
auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, [](Ref* sender){
|
||||||
|
@ -289,6 +290,12 @@ WebSocketCloseTest::WebSocketCloseTest()
|
||||||
addChild(notifyLabel, 1);
|
addChild(notifyLabel, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebSocketCloseTest::~WebSocketCloseTest()
|
||||||
|
{
|
||||||
|
if (_wsiTest)
|
||||||
|
_wsiTest->close();
|
||||||
|
}
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
void WebSocketCloseTest::onOpen(network::WebSocket* ws)
|
void WebSocketCloseTest::onOpen(network::WebSocket* ws)
|
||||||
{
|
{
|
||||||
|
@ -303,7 +310,8 @@ void WebSocketCloseTest::onMessage(network::WebSocket* ws, const network::WebSoc
|
||||||
void WebSocketCloseTest::onClose(network::WebSocket* ws)
|
void WebSocketCloseTest::onClose(network::WebSocket* ws)
|
||||||
{
|
{
|
||||||
log("websocket (%p) closed.", ws);
|
log("websocket (%p) closed.", ws);
|
||||||
CC_SAFE_DELETE(ws);
|
delete ws;
|
||||||
|
_wsiTest = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketCloseTest::onError(network::WebSocket* ws, const network::WebSocket::ErrorCode& error)
|
void WebSocketCloseTest::onError(network::WebSocket* ws, const network::WebSocket::ErrorCode& error)
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
virtual void onError(cocos2d::network::WebSocket* ws, const cocos2d::network::WebSocket::ErrorCode& error)override;
|
virtual void onError(cocos2d::network::WebSocket* ws, const cocos2d::network::WebSocket::ErrorCode& error)override;
|
||||||
|
|
||||||
WebSocketCloseTest();
|
WebSocketCloseTest();
|
||||||
|
~WebSocketCloseTest();
|
||||||
|
|
||||||
virtual std::string title() const override { return "WebSocket close by resetDirector event Test"; }
|
virtual std::string title() const override { return "WebSocket close by resetDirector event Test"; }
|
||||||
std::string subtitle() const override { return "Click close button, Program should close without crash."; }
|
std::string subtitle() const override { return "Click close button, Program should close without crash."; }
|
||||||
|
|
Loading…
Reference in New Issue