-
Notifications
You must be signed in to change notification settings - Fork 319
Fix MapboxNavigation#detach issue
#6245
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
Conversation
| services.forEach { it.onDetached(mapboxNavigation!!) } | ||
| MapboxNavigationProvider.destroy() | ||
| mapboxNavigation = null | ||
| logI("disabled ${services.size} observers", LOG_CATEGORY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this log because it is useful to figure out how many services are attached when you call disable.
Codecov Report
@@ Coverage Diff @@
## main #6245 +/- ##
============================================
+ Coverage 68.84% 68.86% +0.01%
- Complexity 4336 4338 +2
============================================
Files 650 650
Lines 26102 26104 +2
Branches 3061 3061
============================================
+ Hits 17971 17976 +5
+ Misses 6968 6965 -3
Partials 1163 1163
|
| attached = false | ||
| services.forEach { it.onDetached(mapboxNavigation!!) } | ||
| MapboxNavigationProvider.destroy() | ||
| mapboxNavigation = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is repeated in carAppLifecycleObserver.onStop, looks like it should be moved to a separate function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are still some slight differences like logs and the condition for if (attached)
think i prefer to let them continue to be separate, cover the issues with tests
Description
Found this issue while testing this #6233
mapboxNavigationis still valid after callingdetach. This means all calls tocurrent()will return non-null, and if you unregister an observer it can result detach calls after it has been disabled. It is expected, to have a single onDetached call per every onAttached.I separated this pull request from 6233 because it would definitely impact anyone using
detach.