mirror of https://github.com/axmolengine/axmol.git
Fixed ClippingNode not cleaning up _stencil correctly (#15814)
* Fixed ClippingNode not cleaning up _stencil correctly _stencil may be running due to onEnter() called by ClippingNode. If onExit() is not called then Node::~Node() will assert when _stencil is released. * Added onEnterXXX to ClippingNode::setStencil() ClippingNode::_stencil would not be initialised correctly when set after ClippingNode was adding to the active scene.
This commit is contained in:
parent
925e938724
commit
dd6fed7928
|
@ -290,6 +290,7 @@ Node* ClippingNode::getStencil() const
|
|||
|
||||
void ClippingNode::setStencil(Node *stencil)
|
||||
{
|
||||
//early out if the stencil is already set
|
||||
if (_stencil == stencil)
|
||||
return;
|
||||
|
||||
|
@ -303,9 +304,26 @@ void ClippingNode::setStencil(Node *stencil)
|
|||
sEngine->retainScriptObject(this, stencil);
|
||||
}
|
||||
#endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS
|
||||
CC_SAFE_RETAIN(stencil);
|
||||
CC_SAFE_RELEASE(_stencil);
|
||||
|
||||
//cleanup current stencil
|
||||
if(_stencil != nullptr && _stencil->isRunning())
|
||||
{
|
||||
_stencil->onExitTransitionDidStart();
|
||||
_stencil->onExit();
|
||||
}
|
||||
CC_SAFE_RELEASE_NULL(_stencil);
|
||||
|
||||
//initialise new stencil
|
||||
_stencil = stencil;
|
||||
CC_SAFE_RETAIN(_stencil);
|
||||
if(_stencil != nullptr && this->isRunning())
|
||||
{
|
||||
_stencil->onEnter();
|
||||
if(this->_isTransitionFinished)
|
||||
{
|
||||
_stencil->onEnterTransitionDidFinish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ClippingNode::hasContent() const
|
||||
|
|
Loading…
Reference in New Issue