[Orxonox-commit 2371] r7086 - code/branches/presentation3/src/modules/pickup

landauf at orxonox.net landauf at orxonox.net
Wed Jun 2 18:47:57 CEST 2010


Author: landauf
Date: 2010-06-02 18:47:57 +0200 (Wed, 02 Jun 2010)
New Revision: 7086

Modified:
   code/branches/presentation3/src/modules/pickup/PickupSpawner.cc
Log:
Fixed a bug in PickupSpawner.

When one Pawn picked up the last item, spawnsRemaining_ became 0 and the PickupSpawner was destroyed immediately. But PickupSpawner::tick() continued iterating through the other pawns, which lead to a crash.

Modified: code/branches/presentation3/src/modules/pickup/PickupSpawner.cc
===================================================================
--- code/branches/presentation3/src/modules/pickup/PickupSpawner.cc	2010-06-02 16:09:31 UTC (rev 7085)
+++ code/branches/presentation3/src/modules/pickup/PickupSpawner.cc	2010-06-02 16:47:57 UTC (rev 7086)
@@ -175,6 +175,8 @@
         //! If the PickupSpawner is active.
         if (this->isActive())
         {
+            SmartPtr<PickupSpawner> temp = this; // create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
+            
             //! Iterate trough all Pawns.
             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
             {




More information about the Orxonox-commit mailing list