[Orxonox-commit 3298] r7987 - code/branches/usability/src/modules/notifications

dafrick at orxonox.net dafrick at orxonox.net
Sun Feb 27 11:32:08 CET 2011


Author: dafrick
Date: 2011-02-27 11:32:08 +0100 (Sun, 27 Feb 2011)
New Revision: 7987

Modified:
   code/branches/usability/src/modules/notifications/NotificationManager.cc
   code/branches/usability/src/modules/notifications/NotificationQueue.cc
Log:
Hopefully fixing two bugs.


Modified: code/branches/usability/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/usability/src/modules/notifications/NotificationManager.cc	2011-02-27 10:00:06 UTC (rev 7986)
+++ code/branches/usability/src/modules/notifications/NotificationManager.cc	2011-02-27 10:32:08 UTC (rev 7987)
@@ -102,8 +102,12 @@
     void NotificationManager::preDestroy(void)
     {
         // Destroys all NotificationQueues that have been registered with the NotificationManager.
-        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++)
+        std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin();
+        while(it != this->queues_.end())
+        {
             it->second->destroy(true);
+            it = this->queues_.begin();
+        }
 
         this->queues_.clear();
     }
@@ -297,12 +301,12 @@
             delete map;
         }
 
+        COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl;
+
         // Remove the NotificationListener from the list of NotificationListeners.
         this->listenerList_.erase(listener);
         // Remove the Notifications list that was associated with the input NotificationListener.
         this->notificationLists_.erase(identifier);
-
-        COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;
     }
 
     /**
@@ -360,6 +364,7 @@
     */
     bool NotificationManager::registerQueue(NotificationQueue* queue)
     {
+        COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl;
         return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;
     }
 
@@ -371,6 +376,7 @@
     */
     void NotificationManager::unregisterQueue(NotificationQueue* queue)
     {
+        COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl;
         this->queues_.erase(queue->getName());
     }
 

Modified: code/branches/usability/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/branches/usability/src/modules/notifications/NotificationQueue.cc	2011-02-27 10:00:06 UTC (rev 7986)
+++ code/branches/usability/src/modules/notifications/NotificationQueue.cc	2011-02-27 10:32:08 UTC (rev 7987)
@@ -136,6 +136,8 @@
         if(GameMode::showsGraphics() && !noGraphics)
             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
 
+        COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;
+
         this->OrxonoxClass::destroy();
     }
 
@@ -166,9 +168,8 @@
             // Iterate through all elements whose creation time is smaller than the current time minus the display time.
             while(it != this->ordering_.upper_bound(&this->timeLimit_))
             {
-                std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator temp = it;
-                it++;
-                this->remove(temp); // Remove the Notifications that have expired.
+                this->remove(it); // Remove the Notifications that have expired.
+                it = this->ordering_.begin();
             }
 
             this->tickTime_ = this->tickTime_ - (int)this->tickTime_; // Reset time counter.
@@ -247,6 +248,8 @@
         // Push the Notification to the GUI.
         if(GameMode::showsGraphics())
             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
+
+        COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
     }
 
     /**
@@ -258,11 +261,13 @@
         NotificationContainer* container = this->notifications_.back();
         // Get all the NotificationContainers that were sent the same time the NotificationContainer we want to pop was sent.
         std::pair<std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator, std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator> iterators = this->ordering_.equal_range(container);
+
         // Iterate through all suspects and remove the container as soon as we find it.
         for(std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = iterators.first; it != iterators.second; it++)
         {
             if(container == *it)
             {
+                COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" popped from NotificationQueue '" << this->getName() << "'" << endl;
                 this->ordering_.erase(it);
                 break;
             }
@@ -289,6 +294,9 @@
         std::vector<NotificationContainer*>::iterator it = std::find(this->notifications_.begin(), this->notifications_.end(), *containerIterator);
         // Get the index at which the Notification is.
         std::vector<NotificationContainer*>::difference_type index = it - this->notifications_.begin ();
+
+        COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" removed from NotificationQueue '" << this->getName() << "'" << endl;
+
         this->ordering_.erase(containerIterator);
         this->notifications_.erase(it);
 
@@ -309,6 +317,7 @@
     */
     void NotificationQueue::clear(bool noGraphics)
     {
+        COUT(4) << "Clearing NotificationQueue " << this->getName() << "." << endl;
         this->ordering_.clear();
         // Delete all NotificationContainers in the list.
         for(std::vector<NotificationContainer*>::iterator it = this->notifications_.begin(); it != this->notifications_.end(); it++)
@@ -371,7 +380,7 @@
 
     /**
     @brief
-        Produces all targets of the NotificationQueue concatinated as string, with kommas (',') as seperators.
+        Produces all targets of the NotificationQueue concatinated as string, with commas (',') as seperators.
     @return
         Returns the targets as a string.
     */




More information about the Orxonox-commit mailing list