Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2009, 12:50:22 AM (14 years ago)
Author:
rgrieder
Message:

Adding OrxonoxClass::preDestroy(). This method gets called when an object is about to be destroyed. The only way to prevent that is by overriding preDestroy() and then creating a SmartPtr to 'this'. This allows us to delay the destruction of an object, for instance when destroyed by the loader.

File:
1 edited

Legend:

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

    r6121 r6348  
    135135            {   return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID);   }
    136136
     137        protected:
     138            virtual void preDestroy() {}
     139
    137140        private:
    138141            /** @brief Increments the reference counter (for smart pointers). */
     
    141144            /** @brief Decrements the reference counter (for smart pointers). */
    142145            inline void decrementReferenceCount()
    143                 { --this->referenceCount_; if (this->referenceCount_ == 0 && this->requestedDestruction_) { delete this; } }
     146            {
     147                --this->referenceCount_;
     148                if (this->referenceCount_ == 0 && this->requestedDestruction_)
     149                    this->destroy();
     150            }
    144151               
    145152            /** @brief Register a weak pointer which points to this object. */
Note: See TracChangeset for help on using the changeset viewer.