mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6040 from dumganhar/develop
Two fixes: 1) ParticleSystem should also override onExit to unschedule update since in onEnter, it will be scheduled again. Otherwise, it'll trigger an assert. 2) User object has to be released before others, since userObject may have a weak reference of this node. It may invoke node->stopAllAction(); while _actionManager is null if the next line is after CC_SAFE_RELEASE_NULL(_actionManager).
This commit is contained in:
commit
9090e2015c
|
@ -154,6 +154,10 @@ Node::~Node()
|
|||
}
|
||||
#endif
|
||||
|
||||
// User object has to be released before others, since userObject may have a weak reference of this node
|
||||
// It may invoke `node->stopAllAction();` while `_actionManager` is null if the next line is after `CC_SAFE_RELEASE_NULL(_actionManager)`.
|
||||
CC_SAFE_RELEASE_NULL(_userObject);
|
||||
|
||||
CC_SAFE_RELEASE_NULL(_actionManager);
|
||||
CC_SAFE_RELEASE_NULL(_scheduler);
|
||||
|
||||
|
@ -162,7 +166,6 @@ Node::~Node()
|
|||
|
||||
// attributes
|
||||
CC_SAFE_RELEASE_NULL(_shaderProgram);
|
||||
CC_SAFE_RELEASE_NULL(_userObject);
|
||||
|
||||
for (auto& child : _children)
|
||||
{
|
||||
|
|
|
@ -624,6 +624,12 @@ void ParticleSystem::onEnter()
|
|||
this->scheduleUpdateWithPriority(1);
|
||||
}
|
||||
|
||||
void ParticleSystem::onExit()
|
||||
{
|
||||
this->unscheduleUpdate();
|
||||
Node::onExit();
|
||||
}
|
||||
|
||||
void ParticleSystem::stopSystem()
|
||||
{
|
||||
_isActive = false;
|
||||
|
|
|
@ -191,7 +191,6 @@ public:
|
|||
//! whether or not the system is full
|
||||
bool isFull();
|
||||
|
||||
virtual void onEnter();
|
||||
//! should be overridden by subclasses
|
||||
virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition);
|
||||
//! should be overridden by subclasses
|
||||
|
@ -355,6 +354,8 @@ public:
|
|||
inline void setPositionType(PositionType type) { _positionType = type; };
|
||||
|
||||
// Overrides
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual void update(float dt) override;
|
||||
virtual Texture2D* getTexture() const override;
|
||||
virtual void setTexture(Texture2D *texture) override;
|
||||
|
|
Loading…
Reference in New Issue