Fixed crash on location engine access and location request hang #535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I discovered that in certain cases
getLocationEngine()
can be called even if location component was not activated (possibly if someone tried to activate it before style was loaded), causing an unhandled exception (see #534). I have no idea why a getter call would ever need to crash, but here we are.I added
isLocationComponentActivated()
check in every place wheregetLocationEngine()
is called. It is not the most elegant solution for sure, but since there are other checks in place it seemed appropriate and allowed me to avoid wrapping the getter in another getter.I also added missing else branch in
getLastLocation
call handler. I chose "LOCATION DISABLED" as an error code since I could not find any standardized list of error codes. Feel free to suggest alternatives.