From daa6841b2d2d2d4de530ffe01123fa62c1336e73 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Dec 2013 21:07:24 +0300 Subject: fix possible pets leak. --- src/actormanager.cpp | 5 +++-- src/being/being.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/actormanager.cpp b/src/actormanager.cpp index d7a272284..e28f999fd 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -792,8 +792,9 @@ void ActorManager::logic() FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors) { - mActors.erase(*it); - delete *it; + ActorSprite *actor = *it; + mActors.erase(actor); + delete actor; } mDeleteActors.clear(); diff --git a/src/being/being.cpp b/src/being/being.cpp index 90c5cb316..383c3a14a 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -243,7 +243,12 @@ Being::~Being() if (mOwner) mOwner->setPet(nullptr); if (mPet) + { mPet->setOwner(nullptr); + actorManager->erase(mPet); + delete mPet; + mPet = nullptr; + } removeAllItemsParticles(); } @@ -2921,7 +2926,6 @@ std::string Being::loadComment(const std::string &name, const int type) } str.append(stringToHexPath(name)).append("/comment.txt"); - logger->log("load from: %s", str.c_str()); const ResourceManager *const resman = ResourceManager::getInstance(); if (resman->existsLocal(str)) @@ -3143,7 +3147,8 @@ void Being::removePet() if (mPet) { mPet->setOwner(nullptr); - actorManager->destroy(mPet); + actorManager->erase(mPet); + delete mPet; mPet = nullptr; } } -- cgit v1.2.3-70-g09d2