Fix crash when attempting to clear pending GlideImage loads.

Hold a reference to the Glide RequestManager instead of creating a new instance when attempting to clear pending loads and free resources for the target.
This commit is contained in:
jeffrey-signal
2025-07-09 11:46:42 -04:00
committed by Alex Hart
parent e6ca41c0f9
commit a88394ffe4

View File

@@ -114,7 +114,8 @@ private fun <T> GlideImage(
val density = LocalDensity.current
val context = LocalContext.current
DisposableEffect(model, fallback, error, diskCacheStrategy, density, imageSize) {
val builder = Glide.with(context)
val requestManager = Glide.with(context)
val builder = requestManager
.load(model)
.fallback(fallback)
.error(error)
@@ -134,7 +135,7 @@ private fun <T> GlideImage(
object : DisposableEffectResult {
override fun dispose() {
Glide.with(context).clear(target)
requestManager.clear(target)
drawable = null
}
}