Ignore:
Timestamp:
Mar 18, 2013, 6:29:41 PM (13 years ago)
Author:
Frederik Heber <heber@…>
Children:
3f30cc
Parents:
b9273a
git-author:
Frederik Heber <heber@…> (03/18/13 18:22:47)
git-committer:
Frederik Heber <heber@…> (03/18/13 18:29:41)
Message:

Channels and Notifications pass on subjectKilled().

  • if we only sign on to a single notification channel, we miss on subjectKilled() completely. Hence, we have to chance of properly signing off again or, at least, to know that we must not anymore.
  • Hence, Observable's dstor now calls subjectKilled() on its Channels which passes the call on to all its Notifications that in turn use the subjectKilled() slot of their targets along with the passed-through Observable instance.
  • also added observerLog verbosity when signing on/off to channels.
  • explained this in header documentation of Observable, Channels, and Notification.
  • TESTFIX: ObserverUnitTest did not properly signOff() before deleting instances in relayNotificationTest().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Observer/Channels.cpp

    rb9273a r1c291d  
    3434  for(NotificationTypetoRefMap::iterator iter = ChannelMap.begin();
    3535      !ChannelMap.empty(); iter = ChannelMap.begin()) {
    36     delete iter->second;
    37     ChannelMap.erase(iter);
     36    removeChannel(iter->first);
    3837  }
    3938}
     
    4140void Channels::addChannel(size_t no)
    4241{
     42#ifdef NDEBUG
    4343  NotificationTypetoRefMap::const_iterator iter = ChannelMap.find(no);
    4444  ASSERT(iter == ChannelMap.end(),
    4545      "Channels::addChannel() - channel "+toString(int(no))+" is already present in ChannelMap.");
     46#endif
    4647  ChannelMap.insert( std::make_pair(no, new Notification(no)) );
    4748}
     
    5455  delete iter->second;
    5556  ChannelMap.erase(iter);
     57}
     58
     59void Channels::subjectKilled(Observable * const publisher)
     60{
     61  for(NotificationTypetoRefMap::iterator iter = ChannelMap.begin();
     62      iter != ChannelMap.end();++iter) {
     63    iter->second->subjectKilled(publisher);
     64  }
    5665}
    5766
Note: See TracChangeset for help on using the changeset viewer.