Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 29, 2009, 10:27:10 PM (15 years ago)
Author:
rgrieder
Message:

Derived all singletons implemented in a usual manner from orxonox::Singleton<T>.
This resolves inconsistencies with the singletonPtr_s variable in case of exceptions (asserts were being triggered then).
And while at it replaced singletonRef_s with singletonPtr_s for it to be less misleading (as fabian has already pointed out).

Location:
code/branches/resource/src/orxonox/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/orxonox/sound/SoundManager.cc

    r3342 r3366  
    3838namespace orxonox
    3939{
    40     SoundManager* SoundManager::singletonRef_s = NULL;
     40    SoundManager* SoundManager::singletonPtr_s = NULL;
    4141
    4242    /**
     
    4545    SoundManager::SoundManager()
    4646    {
    47         assert(singletonRef_s == NULL);
    48         singletonRef_s = this;
    49 
    5047        this->device_ = NULL;
    5148        this->soundavailable_ = true;
     
    9390    SoundManager::~SoundManager()
    9491    {
    95         assert(singletonRef_s != NULL);
    96         singletonRef_s = NULL;
    97 
    9892        alcDestroyContext(this->context_);
    9993        alcCloseDevice(this->device_);
  • code/branches/resource/src/orxonox/sound/SoundManager.h

    r3280 r3366  
    3232#include <cassert>
    3333#include <list>
     34#include "util/Singleton.h"
    3435#include "interfaces/Tickable.h"
    3536
     
    4243     *
    4344     */
    44     class _OrxonoxExport SoundManager : public Tickable
     45    class _OrxonoxExport SoundManager : public Singleton<SoundManager>, public Tickable
    4546    {
     47        friend class Singleton<SoundManager>;
    4648    public:
    4749        SoundManager();
     
    5254        bool isSoundAvailable();
    5355
    54         static SoundManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
    55 
    5656    private:
    5757        ALCdevice* device_;
     
    6060        bool soundavailable_;
    6161
    62         static SoundManager* singletonRef_s;
     62        static SoundManager* singletonPtr_s;
    6363    }; // class SoundManager
    6464} // namespace orxonox
Note: See TracChangeset for help on using the changeset viewer.