Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2010, 10:36:48 PM (14 years ago)
Author:
dafrick
Message:

A lot of cleanup, mostly increasing output levels, which means, that the console is no longer cluttered by lots and lots of Quest-stuff (the log file still is, but that should be ok…).
Also some possible bugs (or let's say pitfalls) removed, which have been around for a long time and didn't cause any problems so far. Now they never will.
Also, regarding my previous commit. Quests seem tu work just fine, even the second time the level is loaded, which is awesome.

Ergo: Questsystem/Notificationsystem segfault upon loading a level with Quests/Notifications in it twice is now officially resolved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc

    r6944 r6945  
    118118    @brief
    119119        Unregisters a Notification within the NotificationManager.
     120    @param notification
     121        A pointer to the Notification to be unregistered.
     122    @param listener
     123        A pointer to the NotificationListener the Notification is unregistered for.
    120124    */
    121125    void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener)
     
    124128        assert(listener);
    125129
     130        // If the Notification was removed from the list of Notifications of the input NotificationListener, the counter for the Notification of the number of NotificationListeners it is present in is decremented.
    126131        if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second)))
    127132            this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1;
     133
     134        // If the Notification is no longer present in any of the NotificationListeners it can be removed from the map of all Notifications and be destroyed.
    128135        if(this->listenerCounter_[notification] == (unsigned int) 0)
    129136        {
    130137            this->removeNotification(notification, this->allNotificationsList_);
     138            this->listenerCounter_.erase(notification);
    131139            notification->destroy();
    132140        }
     
    138146    @brief
    139147        Helper method that removes an input notification form an input map.
     148    @param notification
     149        A pointer to the notification to be removed.
     150    @param map
     151        The map the notification should be removed from.
     152    @return
     153        Returns true if successful.
    140154    */
    141155    bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map)
    142156    {
     157        // Iterates through all items in the map until the Notification is found.
     158        //TODO: Do more efficiently?
    143159        for(std::multimap<std::time_t, Notification*>::iterator it = map.begin(); it != map.end(); it++)
    144160        {
     
    222238        this->listenerList_.erase(listener);
    223239        this->notificationLists_.erase(identifier);
    224         delete map;
     240
     241        // If the map is not the map of all notifications, delete it.
     242        if(map != &this->allNotificationsList_)
     243            delete map;
    225244
    226245        COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;
Note: See TracChangeset for help on using the changeset viewer.