mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix memory problems with BonusList
Bonus * -> std::shared_ptr<Bonus> This cures the following problems: 1) Memory corruption at exit. Some Bonus-es were deleted twice (mods?). 2) Memory leaks. Some Bonuses were not deleted. 3) Reduce the number of "Orphaned child" messages. Valgrind reports 0 leaked memory now and no invalid reads/writes.
This commit is contained in:
@@ -678,7 +678,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
|
||||
case ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED:
|
||||
{
|
||||
//Recanter's Cloak or similar effect. Try to retrieve bonus
|
||||
const Bonus *b = owner->myHero->getBonusLocalFirst(Selector::type(Bonus::BLOCK_MAGIC_ABOVE));
|
||||
const auto b = owner->myHero->getBonusLocalFirst(Selector::type(Bonus::BLOCK_MAGIC_ABOVE));
|
||||
//TODO what about other values and non-artifact sources?
|
||||
if(b && b->val == 2 && b->source == Bonus::ARTIFACT)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user