-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fixed removing multiple listeners within event callbacks #5827 #5833
Conversation
@speigg, thanks for the pull request! Maintainers, we have a signed CLA from @speigg, so you can review this at any time. I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to I am a bot who helps you make Cesium awesome! Thanks again. |
Thanks for the PR @speigg ! If you add |
CHANGES.md
Outdated
@@ -1,5 +1,8 @@ | |||
Change Log | |||
========== | |||
|
|||
* Fixed removing multiple event listeners within event callbacks. [#5827](https://github.com/AnalyticalGraphicsInc/cesium/issues/5827) |
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.
Add this bullet under the next release, under ### 1.38 - 2017-10-02
@@ -120,6 +120,10 @@ define([ | |||
return false; | |||
}; | |||
|
|||
function compareNumber(a,b) { |
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.
Since this is so short, it can probably be inline.
toRemove.sort(function (a, b) {
...
});
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.
Wouldn't that add an unnecessary callback allocation every time an event is raised (thus creating garbage and requiring the GC to be invoked more often)?
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.
That's true, fair enough!
Specs/Core/EventSpec.js
Outdated
var remove; | ||
var listener = function() { | ||
if (index % 2 === 0) { | ||
remove(); |
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.
This test is a little hard to follow. Can you try structuring it a little more linearly like the other tests?
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.
Sure
@ggetz I've rewritten the test case to make it simpler, as you suggested |
Fixed a bug that occurs when removing multiple event listeners within an event callback (see #5827). Added a test case to EventSpec.