Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10419 for code


Ignore:
Timestamp:
May 3, 2015, 2:39:30 PM (10 years ago)
Author:
landauf
Message:

added destroyLater() to Destroyable. This will destroy the object (like destroy()) but not until the current tick has ended.

Location:
code/branches/core7/src/libraries/core
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/CorePrereqs.h

    r10413 r10419  
    157157    class Core;
    158158    class Destroyable;
     159    class DestroyLaterManager;
    159160    class DestructionListener;
    160161    class DynLib;
  • code/branches/core7/src/libraries/core/object/CMakeLists.txt

    r9667 r10419  
    22  Context.cc
    33  Destroyable.cc
     4  DestroyLaterManager.cc
    45  Listable.cc
    56  ObjectListBase.cc
  • code/branches/core7/src/libraries/core/object/Destroyable.cc

    r9944 r10419  
    3333
    3434#include "Destroyable.h"
     35#include "DestroyLaterManager.h"
    3536
    3637#include <cassert>
     
    7475        }
    7576    }
     77
     78    /**
     79     * Works like @ref destroy() but doesn't destroy the object until the current tick has ended.
     80     */
     81    void Destroyable::destroyLater()
     82    {
     83        // register in DestroyLaterManager - this ensures that a smartPtr points to this object and keeps it alive for a while
     84        DestroyLaterManager::getInstance().retain(this);
     85
     86        // request destruction -> object will be deleted after all smartPtrs (including the one in DestroyLaterManager) were destroyed.
     87        this->destroy();
     88    }
    7689}
  • code/branches/core7/src/libraries/core/object/Destroyable.h

    r9944 r10419  
    5757
    5858            void destroy();
     59            void destroyLater();
    5960
    6061            /// Returns the number of @ref orxonox::SmartPtr "smart pointers" that point to this object.
Note: See TracChangeset for help on using the changeset viewer.