OGRECave / ogre

scene-oriented, flexible 3D engine (C++, Python, C#, Java)
https://ogrecave.github.io/ogre/
MIT License
3.83k stars 957 forks source link

PCZSceneManager might have a memory leak as it doesn't delete mAntiPortals #3132

Closed Hotshot5000 closed 1 month ago

Hotshot5000 commented 1 month ago

In PCZSceneManager destructor I see that mPortals get deleted but mAntiPortals are not deleted. Same in init() only mPortals get deleted.

Hotshot5000 commented 1 month ago

Should probably be something like this: `PCZSceneManager::~PCZSceneManager() { // we don't delete the root scene node here because the // base scene manager class does that.

    // delete ALL portals
    Portal * p;
    PortalList::iterator i = mPortals.begin();
    for (i = mPortals.begin(); i != mPortals.end(); i++)
    {
        p = *i;
        OGRE_DELETE p;
    }
    mPortals.clear();

    AntiPortal * ap;
    AntiPortalList::iterator iap = mAntiPortals.begin();
    for (iap = mAntiPortals.begin(); iap != mAntiPortals.end(); iap++)
    {
        ap = *iap;
        OGRE_DELETE ap;
    }
    mAntiPortals.clear();

    // delete all the zones
    for (ZoneMap::iterator j = mZones.begin();
        j != mZones.end(); ++j)
    {
        OGRE_DELETE j->second;
    }
    mZones.clear();
    mDefaultZone = 0;
}`
paroj commented 1 month ago

sounds valid. can you provide a pull-request?

Hotshot5000 commented 1 month ago

https://github.com/OGRECave/ogre/pull/3134

Waiting for the checks to pass.

EDIT: PR seems validated.