Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2009, 11:12:31 AM (15 years ago)
Author:
scheusso
Message:

trying to solve a double free bug (replaced OrxonoxOverlay pointers with smart pointers)

Location:
code/trunk/src/modules/overlays/hud
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/overlays/hud/HUDHealthBar.cc

    r5929 r6054  
    4848        this->textoverlay_ = new OverlayText(this);
    4949
    50         assert(this->textoverlay_);
     50        assert(this->textoverlay_.get());
    5151
    5252        this->textoverlay_->setCaption("");
     
    5656    {
    5757        if (this->isInitialized())
     58        {
    5859            this->textoverlay_->destroy();
     60            this->textoverlay_ = 0;
     61        }
    5962    }
    6063
     
    106109        SUPER(HUDHealthBar, changedOverlayGroup);
    107110
    108         this->getOverlayGroup()->addElement(this->textoverlay_);
     111        this->getOverlayGroup()->addElement(this->textoverlay_.get());
    109112    }
    110113
  • code/trunk/src/modules/overlays/hud/HUDHealthBar.h

    r5929 r6054  
    112112        private:
    113113            WeakPtr<Pawn> owner_;
    114             OverlayText* textoverlay_;
     114            SmartPtr<OverlayText> textoverlay_;
    115115            bool bUseBarColour_;
    116116            ColourValue textColour_;
  • code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc

    r5929 r6054  
    3434#include "gametypes/UnderAttack.h"
    3535#include "worldentities/pawns/Destroyer.h"
     36#include "overlays/OverlayGroup.h"
    3637
    3738namespace orxonox
     
    5859    {
    5960        if (this->isInitialized())
     61        {
    6062            this->text_->destroy();
     63            this->text_ = 0;
     64        }
    6165    }
    6266
     
    9094        }
    9195    }
     96   
     97    void UnderAttackHealthBar::changedOverlayGroup()
     98    {
     99        SUPER(UnderAttackHealthBar, changedOverlayGroup);
     100       
     101        this->getOverlayGroup()->addElement(this->text_.get());
     102    }
    92103
    93104    void UnderAttackHealthBar::init()
  • code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.h

    r5929 r6054  
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4747            virtual void changedOwner();
     48            virtual void changedOverlayGroup();
    4849
    4950            inline void setDescriptionPickPoint(const Vector2& pickpoint)
     
    6162
    6263            PlayerInfo* owner_;
    63             OverlayText* text_;
     64            SmartPtr<OverlayText> text_;
    6465            Timer inittimer_;
    6566    };
Note: See TracChangeset for help on using the changeset viewer.