Ticket #90 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

calling map.destroy causes problem with legend and tree components

Reported by: tschaub Assigned to: ahocevar
Priority: major Milestone: 0.5
Component: widgets Version: SVN
Keywords: Cc:
State: Commit

Description

This may be the same issue Bart is describing in #88, not sure. This is easy to reproduce, so I'm making a new ticket.

It would be nice to have "beforedestroy" and "destroy" events from OpenLayers.

Attachments

destroy_issue.patch (0.7 kB) - added by tschaub on 06/12/09 18:34:52.
demonstration of the problem
ticket90.patch (0.7 kB) - added by bartvde on 06/12/09 20:42:59.
patch fixing the issue, depends on OL ticket 2136
geoext-90.patch (7.5 kB) - added by ahocevar on 06/13/09 00:21:18.
fix the problem at its root
90.patch (7.5 kB) - added by tschaub on 06/16/09 00:01:50.
proper destroy and listener handling

Change History

06/12/09 18:34:52 changed by tschaub

  • attachment destroy_issue.patch added.

demonstration of the problem

06/12/09 20:17:05 changed by bartvde

Hey Tim, you mean so we can stop sending remove events from the LayerStore when the OL map is destroying? I also think that's the solution to these problems.

For my problem I was able to "fix" things by overriding the Ext.Store remove function like this:

    remove : function(record){
        var index = this.data.indexOf(record);
        this.data.removeAt(index);
        if(this.pruneModifiedRecords){
            this.modified.remove(record);
        }
        if(this.snapshot){
            this.snapshot.remove(record);
        }
        if (this.map.paddingForPopups !== null) {
            this.fireEvent("remove", this, record, index);
        }
    },

Ofcourse the paddingForPopups part is just a hack right now to check if the OL map is destroying, ideally we would have events like you correctly state above.

06/12/09 20:31:55 changed by bartvde

Added an OpenLayers enhancement ticket for the destroy events (I think the most important one right now is the beforedestroy event on the Map object):

http://trac.openlayers.org/ticket/2136

06/12/09 20:42:59 changed by bartvde

  • attachment ticket90.patch added.

patch fixing the issue, depends on OL ticket 2136

06/12/09 21:57:17 changed by tschaub

  • status changed from new to closed.
  • resolution set to fixed.

(In [1067]) Avoid endlessly calling onImageLoadError by registering it as a single listener each time the image source is set. r=ahocever (closes #90)

06/12/09 23:31:17 changed by tschaub

  • status changed from closed to reopened.
  • resolution deleted.

Apologies for the typo in the commit. r1067 was meant to close #91.

06/13/09 00:21:18 changed by ahocevar

  • attachment geoext-90.patch added.

fix the problem at its root

06/13/09 00:26:06 changed by ahocevar

  • state changed from None to Review.

The above patch fixes a couple of things that were wrong in LayerNode and LayerContainer: onDestroy is not available in all Ext classes! We have to override destroy here. Also, the LayerNode has to take care to remove events when being destroyed.

Anyway, no need for beforedestroy events from OpenLayers here. Reason: the destroy process of the OL map removes layers, triggering removelayer events, and these get handled by our GeoExt components properly. The problem is that we destroy the tree, but all the destroyed nodes still have all event handlers.

The attached patch fixes the issue. Bart, can you please report which of your issues reported in #88 still remain?

Please review.

06/13/09 00:55:05 changed by tschaub

Nice Andreas!

I'll try to sneak in a review sometime soon (may be Monday). Thanks for tackling this.

06/13/09 09:38:03 changed by bartvde

Hi Andreas, I tested your patch but I am still getting errors in IE7 on reload. I've removed the legend from my app to be sure it's coming from the layer tree. It's still complaining about El._flyweights not being there.

06/13/09 10:08:18 changed by ahocevar

Bart: I would say we continue tracking the IE unload issues in #88 then. I am sure there are more places where we do not take care to clean up after ourselves properly, and we have to fix these. To me, it feels like if OpenLayers destroys everything properly, there should be no need to know when it starts destroying. I'll see if I can come up with a test case showing the unload issues in IE.

06/16/09 00:01:50 changed by tschaub

  • attachment 90.patch added.

proper destroy and listener handling

06/16/09 00:04:04 changed by tschaub

  • owner set to ahocevar.
  • status changed from reopened to new.
  • state changed from Review to Commit.

This looks good. I made some changes to the OL event on/un calls (they only take a single arg, not three).

Please commit.

06/16/09 17:14:17 changed by ahocevar

Thanks Tim for fixing the OL on/un calls -- I was confused with the similar-but-not-the-same on/un methods in OL and Ext.

06/16/09 17:19:11 changed by ahocevar

  • status changed from new to closed.
  • resolution set to fixed.

(In [1086]) clean up after ourselves properly, which we did not do enough and not right before. onDestroy() is not available everywhere in Ext, we have to override destroy(). r=tschaub (closes #90)