[Orxonox-commit 6361] r11018 - in code/trunk/src: libraries/tools modules/pong orxonox/worldentities

landauf at orxonox.net landauf at orxonox.net
Sat Jan 2 20:59:12 CET 2016


Author: landauf
Date: 2016-01-02 20:59:12 +0100 (Sat, 02 Jan 2016)
New Revision: 11018

Modified:
   code/trunk/src/libraries/tools/Timer.cc
   code/trunk/src/libraries/tools/Timer.h
   code/trunk/src/modules/pong/PongAI.cc
   code/trunk/src/orxonox/worldentities/MovableEntity.cc
Log:
I think it's sufficient if Timer is a Listable. A timer is often used as a member object in other classes, so it's probably a bad idea to make it a Destroyable since it will neither be deleted with destroy() nor will it survive the lifespan of its parent even if a StrongPtr references it.

Modified: code/trunk/src/libraries/tools/Timer.cc
===================================================================
--- code/trunk/src/libraries/tools/Timer.cc	2016-01-02 17:13:28 UTC (rev 11017)
+++ code/trunk/src/libraries/tools/Timer.cc	2016-01-02 19:59:12 UTC (rev 11018)
@@ -103,7 +103,7 @@
     void executeDelayedCommand(Timer* timer, const std::string& command)
     {
         CommandExecutor::execute(command);
-        timer->destroy();
+        delete timer;
         delaytimers.right.erase(timer);
     }
 
@@ -113,7 +113,7 @@
     void killdelays()
     {
         for (boost::bimap<unsigned int, Timer*>::left_map::iterator it = delaytimers.left.begin(); it != delaytimers.left.end(); ++it)
-            it->second->destroy();
+            delete it->second;
 
         delaytimers.clear();
     }
@@ -126,7 +126,7 @@
         boost::bimap<unsigned int, Timer*>::left_map::iterator it = delaytimers.left.find(handle);
         if (it != delaytimers.left.end())
         {
-            it->second->destroy();
+            delete it->second;
             delaytimers.left.erase(it);
         }
     }
@@ -209,7 +209,7 @@
         (*this->executor_)();
 
         if (temp)
-            this->destroy();
+            delete this;
     }
 
     /**

Modified: code/trunk/src/libraries/tools/Timer.h
===================================================================
--- code/trunk/src/libraries/tools/Timer.h	2016-01-02 17:13:28 UTC (rev 11017)
+++ code/trunk/src/libraries/tools/Timer.h	2016-01-02 19:59:12 UTC (rev 11018)
@@ -78,7 +78,7 @@
 
 #include "tools/ToolsPrereqs.h"
 
-#include "core/class/OrxonoxClass.h"
+#include "core/object/Listable.h"
 #include "core/command/ExecutorPtr.h"
 
 namespace orxonox
@@ -101,7 +101,7 @@
         slower/faster if the game-speed is modified. See RealTimer for a timer class which doesn't depend
         on the game time.
     */
-    class _ToolsExport Timer : public OrxonoxClass
+    class _ToolsExport Timer : public Listable
     {
         public:
             Timer();

Modified: code/trunk/src/modules/pong/PongAI.cc
===================================================================
--- code/trunk/src/modules/pong/PongAI.cc	2016-01-02 17:13:28 UTC (rev 11017)
+++ code/trunk/src/modules/pong/PongAI.cc	2016-01-02 19:59:12 UTC (rev 11018)
@@ -77,7 +77,7 @@
     PongAI::~PongAI()
     {
         for (std::list<std::pair<Timer*, char> >::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
-            it->first->destroy();
+            delete it->first;
     }
 
     /**
@@ -379,9 +379,7 @@
         this->movement_ = this->reactionTimers_.front().second;
 
         // Destroy the timer and remove it from the list
-        Timer* timer = this->reactionTimers_.front().first;
-        timer->destroy();
-
+        delete this->reactionTimers_.front().first;
         this->reactionTimers_.pop_front();
     }
 }

Modified: code/trunk/src/orxonox/worldentities/MovableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/MovableEntity.cc	2016-01-02 17:13:28 UTC (rev 11017)
+++ code/trunk/src/orxonox/worldentities/MovableEntity.cc	2016-01-02 19:59:12 UTC (rev 11018)
@@ -60,7 +60,7 @@
     {
         if (this->isInitialized())
             if (this->continuousResynchroTimer_)
-                this->continuousResynchroTimer_->destroy();
+                delete this->continuousResynchroTimer_;
     }
 
     void MovableEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode)




More information about the Orxonox-commit mailing list