Skip to content
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

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

speigg
Copy link
Contributor

@speigg speigg commented Sep 15, 2017

Fixed a bug that occurs when removing multiple event listeners within an event callback (see #5827). Added a test case to EventSpec.

@cesium-concierge
Copy link

@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 CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.

I am a bot who helps you make Cesium awesome! Thanks again.

@speigg speigg changed the title fix #5827 Fixed removing multiple listeners within event callbacks #5827 Sep 15, 2017
@ggetz
Copy link
Contributor

ggetz commented Sep 15, 2017

Thanks for the PR @speigg !

If you add Fixes #5827 to the description, the Fixes keyword will automatically close that issue when we merge this PR.

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)
Copy link
Contributor

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) {
Copy link
Contributor

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) {
    ...
});

Copy link
Contributor Author

@speigg speigg Sep 28, 2017

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)?

Copy link
Contributor

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!

var remove;
var listener = function() {
if (index % 2 === 0) {
remove();
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@speigg
Copy link
Contributor Author

speigg commented Sep 28, 2017

@ggetz I've rewritten the test case to make it simpler, as you suggested

@ggetz
Copy link
Contributor

ggetz commented Sep 28, 2017

Thanks @speigg !

@pjcozzi This looks good to me, did you want any additional reviewers?

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 28, 2017

Thanks @speigg @ggetz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants