Ignore:
Timestamp:
May 5, 2016, 5:14:19 PM (10 years ago)
Author:
Frederik Heber <heber@…>
Children:
4a33f6
Parents:
fa6af2
git-author:
Frederik Heber <heber@…> (05/05/16 11:46:01)
git-committer:
Frederik Heber <heber@…> (05/05/16 17:14:19)
Message:

FIX: Replaced all uses of getInstance() inside dstors to signOff() by stored Observable ptrs.

  • this is cleaner anyway and how it should be done. We require the pointer eventually to signOff. Also, it serves as an indicator to whether we already received subjectKilled() on it.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/QtShapeList.cpp

    rfa6af2 r8c076a  
    5555QtShapeList::QtShapeList(QWidget * _parent) :
    5656    QTreeWidget (_parent),
    57     Observer("QtShapeList")
     57    Observer("QtShapeList"),
     58    observed_shaperegistry(ShapeRegistry::getPointer())
    5859{
    5960  setColumnCount(COLUMNCOUNT);
     
    7071        refill(NULL);
    7172
    72         ShapeRegistry::getInstance().signOn(this);
    73   ShapeRegistry::getInstance().signOn(this, ShapeRegistry::ShapeInserted);
    74   ShapeRegistry::getInstance().signOn(this, ShapeRegistry::ShapeRemoved);
    75   ShapeRegistry::getInstance().signOn(this, ShapeRegistry::SelectionChanged);
     73        observed_shaperegistry->signOn(this);
     74  observed_shaperegistry->signOn(this, ShapeRegistry::ShapeInserted);
     75  observed_shaperegistry->signOn(this, ShapeRegistry::ShapeRemoved);
     76  observed_shaperegistry->signOn(this, ShapeRegistry::SelectionChanged);
    7677
    7778  connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(rowSelected()));
     
    8081QtShapeList::~QtShapeList()
    8182{
    82   ShapeRegistry::getInstance().signOff(this);
    83   ShapeRegistry::getInstance().signOff(this, ShapeRegistry::ShapeInserted);
    84   ShapeRegistry::getInstance().signOff(this, ShapeRegistry::ShapeRemoved);
    85   ShapeRegistry::getInstance().signOff(this, ShapeRegistry::SelectionChanged);
     83  if(observed_shaperegistry) {
     84    observed_shaperegistry->signOff(this);
     85    observed_shaperegistry->signOff(this, ShapeRegistry::ShapeInserted);
     86    observed_shaperegistry->signOff(this, ShapeRegistry::ShapeRemoved);
     87    observed_shaperegistry->signOff(this, ShapeRegistry::SelectionChanged);
     88  }
    8689}
    8790
     
    9093void QtShapeList::recieveNotification(Observable *publisher, Notification_ptr notification)
    9194{
    92   if (static_cast<ShapeRegistry*>(publisher) == ShapeRegistry::getPointer()) {
     95  if (publisher == observed_shaperegistry) {
    9396    switch (notification->getChannelNo()) {
    9497      case ShapeRegistry::ShapeInserted:
     
    150153#endif
    151154
    152 void QtShapeList::subjectKilled(Observable *publisher) {
     155void QtShapeList::subjectKilled(Observable *publisher)
     156{
     157  if (publisher == observed_shaperegistry)
     158    observed_shaperegistry = NULL;
     159  else
     160    ASSERT(0, "QtShapeList::subjectKilled() - unknown publisher "
     161        +toString(publisher));
    153162}
    154163
Note: See TracChangeset for help on using the changeset viewer.