Skip to content

Commit

Permalink
Fixed|libdeng2: Partially notifying a widget tree
Browse files Browse the repository at this point in the history
When notifying a widget tree and stopping halfway, one has to make
sure the appropriate pre/post notifications still occur.

The requirement is that if pre-notification occurs, post-notification
will always occur, too.
  • Loading branch information
skyjake committed Nov 5, 2013
1 parent 3e69a4c commit 6d19297
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions doomsday/libdeng2/src/widgets/widget.cpp
Expand Up @@ -369,35 +369,42 @@ String Widget::uniqueName(String const &name) const

Widget::NotifyArgs::Result Widget::notifyTree(NotifyArgs const &args)
{
if(args.preNotifyFunc)
{
(this->*args.preNotifyFunc)();
}
NotifyArgs::Result result = NotifyArgs::Continue;

bool preNotified = false;

DENG2_FOR_EACH(Instance::Children, i, d->children)
{
if(*i == args.until)
{
return NotifyArgs::Abort;
result = NotifyArgs::Abort;
break;
}

if(args.conditionFunc && !((*i)->*args.conditionFunc)())
continue; // Skip this one.

if(args.preNotifyFunc && !preNotified)
{
preNotified = true;
(this->*args.preNotifyFunc)();
}

((*i)->*args.notifyFunc)();

if((*i)->notifyTree(args) == NotifyArgs::Abort)
{
return NotifyArgs::Abort;
result = NotifyArgs::Abort;
break;
}
}

if(args.postNotifyFunc)
if(args.postNotifyFunc && preNotified)
{
(this->*args.postNotifyFunc)();
}

return NotifyArgs::Continue;
return result;
}

Widget::NotifyArgs::Result Widget::notifySelfAndTree(NotifyArgs const &args)
Expand Down

0 comments on commit 6d19297

Please sign in to comment.