| Index: Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| diff --git a/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp b/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| index b6989e95340be9c2898e92299d30ee579cfe7a56..b4836ed06f681216fa7a5bc7027bf8eb429b7623 100644
|
| --- a/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| +++ b/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| @@ -69,20 +69,23 @@ void DeviceOrientationDispatcher::startListening()
|
| void DeviceOrientationDispatcher::stopListening()
|
| {
|
| WebKit::Platform::current()->setDeviceOrientationListener(0);
|
| + m_lastDeviceOrientationData.clear();
|
| }
|
|
|
| void DeviceOrientationDispatcher::didChangeDeviceOrientation(const WebKit::WebDeviceOrientationData& motion)
|
| {
|
| m_lastDeviceOrientationData = DeviceOrientationData::create(motion);
|
| - bool needsPurge = false;
|
| - for (size_t i = 0; i < m_controllers.size(); ++i) {
|
| +
|
| + m_isDispatching = true;
|
| + // Don't fire controllers removed or added during event dispatch.
|
| + size_t end = m_controllers.size();
|
| + for (size_t i = 0; i < end; ++i) {
|
| if (m_controllers[i])
|
| static_cast<NewDeviceOrientationController*>(m_controllers[i])->didChangeDeviceOrientation(m_lastDeviceOrientationData.get());
|
| - else
|
| - needsPurge = true;
|
| }
|
| + m_isDispatching = false;
|
|
|
| - if (needsPurge)
|
| + if (m_needsPurge)
|
| purgeControllers();
|
| }
|
|
|
|
|