Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7850


Ignore:
Timestamp:
Feb 10, 2011, 10:26:46 PM (13 years ago)
Author:
landauf
Message:

moved if(object) condition from WeakPtr to DestructionListener

Location:
code/trunk/src/libraries/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/OrxonoxClass.h

    r7849 r7850  
    195195        protected:
    196196            inline void registerAsDestructionListener(OrxonoxClass* object)
    197                 { object->registerDestructionListener(this); }
     197                { if (object) { object->registerDestructionListener(this); } }
    198198            inline void unregisterAsDestructionListener(OrxonoxClass* object)
    199                 { object->unregisterDestructionListener(this); }
     199                { if (object) { object->unregisterDestructionListener(this); } }
    200200
    201201            virtual void objectDeleted() = 0;
  • code/trunk/src/libraries/core/WeakPtr.h

    r7849 r7850  
    112112            inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(0)
    113113            {
    114                 if (this->base_)
    115                     this->registerAsDestructionListener(this->base_);
     114                this->registerAsDestructionListener(this->base_);
    116115            }
    117116
     
    119118            inline WeakPtr(const WeakPtr& other) : pointer_(other.pointer_), base_(other.base_), callback_(0)
    120119            {
    121                 if (this->base_)
    122                     this->registerAsDestructionListener(this->base_);
     120                this->registerAsDestructionListener(this->base_);
    123121            }
    124122
     
    127125            inline WeakPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.base_), callback_(0)
    128126            {
    129                 if (this->base_)
    130                     this->registerAsDestructionListener(this->base_);
     127                this->registerAsDestructionListener(this->base_);
    131128            }
    132129
     
    134131            inline ~WeakPtr()
    135132            {
    136                 if (this->base_)
    137                     this->unregisterAsDestructionListener(this->base_);
    138 
     133                this->unregisterAsDestructionListener(this->base_);
    139134            }
    140135
     
    209204            inline void swap(WeakPtr& other)
    210205            {
    211                 if (this->base_)
    212                     this->unregisterAsDestructionListener(this->base_);
    213                 if (other.base_)
    214                     other.unregisterAsDestructionListener(other.base_);
     206                this->unregisterAsDestructionListener(this->base_);
     207                other.unregisterAsDestructionListener(other.base_);
    215208
    216209                {
     
    225218                }
    226219
    227                 if (this->base_)
    228                     this->registerAsDestructionListener(this->base_);
    229                 if (other.base_)
    230                     other.registerAsDestructionListener(other.base_);
     220                this->registerAsDestructionListener(this->base_);
     221                other.registerAsDestructionListener(other.base_);
    231222            }
    232223
Note: See TracChangeset for help on using the changeset viewer.