Skip to content

Commit 00aefcc

Browse files
author
Josh Bernstein
committed
Merge branch '5819_fix_for_empty_icon_tag' of github.com:josh-bernstein/cesium into 5819_fix_for_empty_icon_tag
2 parents 31efd9d + f373ebe commit 00aefcc

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Change Log
1515
* Fixed CZML processing of `velocityReference` within an interval. [#5738](https://github.com/AnalyticalGraphicsInc/cesium/issues/5738)
1616
* Zoom about mouse now maintains camera heading, pitch, and roll [#4639](https://github.com/AnalyticalGraphicsInc/cesium/pull/5603)
1717
* Fixed a bug in `PolylineCollection` preventing the display of more than 16K points in a single collection [#5538](https://github.com/AnalyticalGraphicsInc/cesium/pull/5782)
18+
* Fixed removing multiple event listeners within event callbacks. [#5827](https://github.com/AnalyticalGraphicsInc/cesium/issues/5827)
19+
* Fixed a 3D Tiles point cloud bug causing a stray point to appear at the center of the screen on certain hardware. [#5599](https://github.com/AnalyticalGraphicsInc/cesium/issues/5599)
1820
* Fixed bug with placemarks in imported KML: placemarks with no specified icon would be displayed with default icon (https://github.com/AnalyticalGraphicsInc/cesium/issues/5819)
1921

2022
### 1.37 - 2017-09-01

Source/Core/Event.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ define([
120120
return false;
121121
};
122122

123+
function compareNumber(a,b) {
124+
return b - a;
125+
}
126+
123127
/**
124128
* Raises the event by calling each registered listener with all supplied arguments.
125129
*
@@ -146,12 +150,15 @@ define([
146150
//Actually remove items removed in removeEventListener.
147151
var toRemove = this._toRemove;
148152
length = toRemove.length;
149-
for (i = 0; i < length; i++) {
150-
var index = toRemove[i];
151-
listeners.splice(index, 1);
152-
scopes.splice(index, 1);
153+
if (length > 0) {
154+
toRemove.sort(compareNumber);
155+
for (i = 0; i < length; i++) {
156+
var index = toRemove[i];
157+
listeners.splice(index, 1);
158+
scopes.splice(index, 1);
159+
}
160+
toRemove.length = 0;
153161
}
154-
toRemove.length = 0;
155162

156163
this._insideRaiseEvent = false;
157164
};

Specs/Core/EventSpec.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defineSuite([
4545
expect(spyListener).not.toHaveBeenCalled();
4646
});
4747

48-
it('can remove from withing a callback', function() {
48+
it('can remove from within a callback', function() {
4949
var doNothing = function(evt) {
5050
};
5151

@@ -67,6 +67,25 @@ defineSuite([
6767
expect(event.numberOfListeners).toEqual(0);
6868
});
6969

70+
it('can remove multiple listeners within a callback', function() {
71+
var removeEvent0 = event.addEventListener(function() { removeEvent0(); });
72+
event.addEventListener(function() {});
73+
var removeEvent2 = event.addEventListener(function() { removeEvent2(); });
74+
event.addEventListener(function() {});
75+
var removeEvent4 = event.addEventListener(function() { removeEvent4(); });
76+
event.addEventListener(function() {});
77+
var removeEvent6 = event.addEventListener(function() { removeEvent6(); });
78+
event.addEventListener(function() {});
79+
var removeEvent8 = event.addEventListener(function() { removeEvent8(); });
80+
event.addEventListener(function() {});
81+
82+
expect(event.numberOfListeners).toEqual(10);
83+
event.raiseEvent();
84+
expect(event.numberOfListeners).toEqual(5);
85+
event.raiseEvent();
86+
expect(event.numberOfListeners).toEqual(5);
87+
});
88+
7089
it('addEventListener and removeEventListener works with same function of different scopes', function() {
7190
var Scope = function() {
7291
this.timesCalled = 0;

0 commit comments

Comments
 (0)