[Android] Prevent crash on race condition
Nicolas Pomepuy
git at videolan.org
Tue Sep 10 09:29:29 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Sep 10 09:15:18 2024 +0200| [a1ffefa08146a60136c3f27f48f7f3eb96abb585] | committer: Nicolas Pomepuy
Prevent crash on race condition
Fixes #3083
> https://code.videolan.org/videolan/vlc-android/commit/a1ffefa08146a60136c3f27f48f7f3eb96abb585
---
.../src/org/videolan/vlc/viewmodels/browser/BrowserModel.kt | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserModel.kt
index 01720db751..32a986ebcb 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserModel.kt
@@ -162,9 +162,10 @@ open class BrowserModel(
suspend fun updateMediaPlayed(mw: MediaWrapper) = withContext(Dispatchers.IO) {
if (dataset.getList().contains(mw)) {
- val item = provider.medialibrary.getMedia(mw.id)
- withContext(Dispatchers.Main) {
- dataset.replace(item)
+ provider.medialibrary.getMedia(mw.id)?.let { item ->
+ withContext(Dispatchers.Main) {
+ dataset.replace(item)
+ }
}
}
}
More information about the Android
mailing list