void Geolocation::handleError(PositionError& error) { auto oneShotsCopy = copyToVector(m_oneShots); GeoNotifierVector watchersCopy; m_watchers.getNotifiersVector(watchersCopy); // Clear the lists before we make the callbacks, to avoid clearing notifiers // added by calls to Geolocation methods from the callbacks, and to prevent // further callbacks to these notifiers. GeoNotifierVector oneShotsWithCachedPosition; m_oneShots.clear(); if (error.isFatal()) m_watchers.clear(); else { // Don't send non-fatal errors to notifiers due to receive a cached position. extractNotifiersWithCachedPosition(oneShotsCopy, &oneShotsWithCachedPosition); extractNotifiersWithCachedPosition(watchersCopy, 0); } sendError(oneShotsCopy, error); sendError(watchersCopy, error); // hasListeners() doesn't distinguish between notifiers due to receive a // cached position and those requiring a fresh position. Perform the check // before restoring the notifiers below. if (!hasListeners()) stopUpdating(); // Maintain a reference to the cached notifiers until their timer fires. copyToSet(oneShotsWithCachedPosition, m_oneShots); }