CCParticleSystemQuad extending never call destructor when setAutoRemoveOnFinish(true)

as i understand when imark the emitter with setAutoRemoveOnFinish(true)
it should remove the emitter and somehow trigger the CCParticleSystemQuad so if i extend the CCParticleSystemQuad
it should call the extended CCParticleSystemQuad class distracture what is not happening .
this is my simple class

class CC_DLL ParticleFromFile : public ParticleSystemQuad
{
public:
    
    static ParticleFromFile* create(const std::string& filename);    
CC_CONSTRUCTOR_ACCESS:
     
    ParticleFromFile(const std::string& filename);
    
    virtual ~ParticleFromFile(); 
    
private:
    CC_DISALLOW_COPY_AND_ASSIGN(ParticleFromFile);
};

ParticleFromFile::ParticleFromFile(const std::string& filename) 
    
{
    ;
}

ParticleFromFile* ParticleFromFile::create(const std::string& filename)
{
    ParticleFromFile* ret = new ParticleFromFile(filename);
    
    if (ret->initWithFile(filename))
    {
        ret->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(ret);
    }
    return ret;
}

ParticleFromFile::~ParticleFromFile()
{
    int stop =0;
}

and this is how i setup the emitter

 _emitterLocal = ParticleFromFile::create(stringPilstName);
                 _emitterLocal->setTag(EXPLOSION_FROM_FILE_TAG);
                 _emitterLocal->setAutoRemoveOnFinish(true);
                 _emitterLocal->retain();
                 _emitterLocal->stopSystem();
                 _emitterLocal->unscheduleUpdate();
                 _emitterLocal->scheduleUpdate(); 

and then i start it with

_emitterLocal->resetSystem(); 

now every thing is working fine and the particles working great , but it never removed / cleaned and the destructor never called
what do i miss here ?

Are you sure it’s not being removed from the parent? Just because the destructor isn’t called, doesn’t mean it hasn’t been removed from the parent.

My guess is this is problem:

_emitterLocal->retain();

This is going to bump up the retain count. After adding the particle system to the layer, that is also going to bump up the retain count. When the particle system is auto-removed, that will decrease the retain count, but your retain/release calls are unbalanced. This means that while it’s being removed from the parent, the destructor won’t be called because the retain count doesn’t reach 0.

@Meir_yanovich

Hmm, like @toojuice saidm even I feel that you should remove _emitterLocal->retain() as why are you doing setAutoRemoveOnFinish(true) when you’re setting it to retain. Or either you must write the statement setAutoRemoveOnFinish(true); after _emitterLocal->retain()

Just check it if this works?

Thanks for the reply
so let me get it if i keep the retain it never gos to the destructor ?