Skip to content

Commit 76e1414

Browse files
committed
fix: Ensure the delegate is retained during coroutine lifecycle as value
1 parent 331881e commit 76e1414

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • maplibre-navigation-core/src/iosMain/kotlin/org/maplibre/navigation/core/location/engine

maplibre-navigation-core/src/iosMain/kotlin/org/maplibre/navigation/core/location/engine/AppleLocationEngine.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ open class AppleLocationEngine(private val getLocationTimeout: Duration, private
9595

9696
withTimeoutOrNull(timeout) {
9797
suspendCancellableCoroutine { continuation ->
98-
locationManager.delegate = object : NSObject(), CLLocationManagerDelegateProtocol {
98+
val delegate = object : NSObject(), CLLocationManagerDelegateProtocol {
9999
/**
100100
* Called when the location manager updates the location.
101101
*
@@ -138,6 +138,7 @@ open class AppleLocationEngine(private val getLocationTimeout: Duration, private
138138
locationManager.delegate = null
139139
}
140140

141+
locationManager.delegate = delegate
141142
locationManager.requestLocation()
142143
}
143144
} ?: locationManager.location?.toLocation()

0 commit comments

Comments
 (0)