foam-framework / foam

Feature-Oriented Active Modeller
Apache License 2.0
787 stars 55 forks source link

Phantom DAO unlisten #428

Closed jacksonic closed 8 years ago

jacksonic commented 8 years ago

A phantom DAO unlisten is happening on builder start

jacksonic commented 8 years ago

Related to #430, but that wasn't the root cause.

jacksonic commented 8 years ago

Looks like FutureDAO's listener management causes this problem:

      this.future(function(delegate) {
        var listeners = this.daoListeners_;
        this.daoListeners_ = [];
        this.delegate = delegate;
        this.daoListeners_ = listeners;
      }.bind(this));

When daoListeners_ is suppressed, the delegate doesn't get its listeners hooked up. If the delegate is later moved into another proxyDAO, it assumes there's a listener to clean up. Specifically, this happens in CachingDAO when the delegate is sent to the FutureDAO, then the FutureDAO is removed and the delegate replaces the futureDAO. Re-ordering the future.set and dao swap hides the problem.