-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dispose layer tree node event listeners. #357
Conversation
Any chance you can add some tests? On first glance this looks fine. Also, is #358 a replacement? |
There are no explicit tests for GeoExt.tree.LayerNode right now so I was a bit hesitant and deferred it. I'm happy to help but will not have time to look into this before the weekend. |
var target = this.target, | ||
layer = target.get('layer') | ||
|
||
if (evt.layer !== layer) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also use curly braces around one liners.
Have you tried (untested): // …
init: function(target) {
this.target = target;
this.target.addListener('beforedestroy', this.cleanupMethod, this);
// …
}
// … Except for this and two other comments this is good to go. |
Yes, I tried that. |
I will give my OK for a merge if we add a big TODO somewhere and maybe even an issue as the approach seems more than hackish to me. Nonetheless the result is better than what we had before, so plus one for merging this once it is updated with a big TODO. Can you update this @bentrm? |
I agree, absolutely. Will add a TODO. |
Hi guys, |
Promise to take care of this this afternoon. Sorry about that, I know you want to ship on 4th. |
I amended the last commit to include TODOs hope you're ok with that. Thanks for your patience. |
👍 thanks! |
Dispose layer tree node event listeners.
I think there are some dangling event listeners associated with the layer node. I hope to fix this with this PR.
As far as I can tell, there is no reasonable way to hook into the destruction of the LayerTreeModel of the LayerNode to fix this so I used the maps 'removelayer' event. 'preremovelayer' is not an option as other listeners outside of this scope may cancel removing the layer. That's also the reason for caching a reference to the actual map. When 'removelayer' is called the layers map property is already lost.