[Orxonox-commit 4582] r9253 - code/trunk/src/modules/notifications

landauf at orxonox.net landauf at orxonox.net
Mon May 28 00:13:01 CEST 2012


Author: landauf
Date: 2012-05-28 00:13:00 +0200 (Mon, 28 May 2012)
New Revision: 9253

Modified:
   code/trunk/src/modules/notifications/NotificationQueue.cc
Log:
fixed crash in NotificationQueue - iterators are not guaranteed to be accessible after erasing them from the set

Modified: code/trunk/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationQueue.cc	2012-05-27 22:00:53 UTC (rev 9252)
+++ code/trunk/src/modules/notifications/NotificationQueue.cc	2012-05-27 22:13:00 UTC (rev 9253)
@@ -44,7 +44,7 @@
 {
 
     CreateFactory(NotificationQueue);
-    
+
     /**
     @brief
         Default constructor. Registers and initializes the object.
@@ -61,7 +61,7 @@
         this->displayTime_ = NotificationQueue::DEFAULT_DISPLAY_TIME;
 
         this->creationTime_ = std::time(0);
-        
+
         this->registerVariables();
     }
 
@@ -110,7 +110,7 @@
 
         if(this->isRegistered())
             this->clear();
-            
+
         this->create();
 
         this->targetsChanged();
@@ -170,8 +170,8 @@
         XMLPortParam(NotificationQueue, "size", setMaxSize, getMaxSize, xmlelement, mode);
         XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlelement, mode);
     }
-    
-    
+
+
     /**
     @brief
         Registers Variables to be Synchronised.
@@ -312,13 +312,13 @@
 
         orxout(verbose_more, context::notifications) << "Notification \"" << (*it)->notification->getMessage() << "\" removed from NotificationQueue '" << this->getName() << "'" << endl;
 
+        delete *containerIterator;
+
         this->ordering_.erase(containerIterator);
         this->notifications_.erase(it);
 
         this->size_--;
 
-        delete *containerIterator;
-
         // TODO: index automatically cast?
         // Inform that a Notification was removed.
         this->notificationRemoved(index);
@@ -369,7 +369,7 @@
             orxout(internal_warning, context::notifications) << "Trying to set maximal size of NotificationQueue '" << this->getName() << "' to 0. Ignoring..." << endl;
             return;
         }
-        
+
         this->maxSize_ = size;
         this->maxSizeChanged();
     }
@@ -399,7 +399,7 @@
         {
             orxout(internal_warning, context::notifications) << "Trying to set display time of NotificationQueue '" << this->getName() << "' to non-positive value. Ignoring..." << endl;
         }
-            
+
         this->displayTime_ = time;
         this->displayTimeChanged();
     }




More information about the Orxonox-commit mailing list