|
From: Ferdinando A. <na...@am...> - 2012-02-07 15:04:33
|
Hi Luca
On Sun, Feb 5, 2012 at 9:26 PM, Luca Billi <luc...@gm...> wrote:
> I noticed that the current implementation of LazyObjects generates
> infinite recursions
> in the case the dependency hierarchy among Observer/Observable objects
> contains loops.
>
> A suggestion to break the infinite recursion is to replace the update()
> method as follows:
> [...]
good catch, even if on the 1.2.0 release branch it was already fixed as in
the following
inline void LazyObject::update() {
// forwards notifications only the first time
if (calculated_) {
// set to false early, otherways non-lazy observers would be
// served obsolete data because of calculated_ being still true
calculated_ = false;
// observers don't expect notifications from frozen objects
if (!frozen_)
notifyObservers();
}
}
I've added your "prevent infinite recursion" comment too
ciao -- Nando
|