mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Fix cursor crash in ConversationSettings.
Best way to fix a cursor crash it to... stop using cursors. Fairly confident the crash was caused by us closing the cursor while it was read. And there just isn't a good way to avoid that with how it was written. So this ended up being a great excuse to move over to models.
This commit is contained in:
@@ -143,13 +143,19 @@ class MediaTable internal constructor(context: Context?, databaseHelper: SignalD
|
||||
}
|
||||
}
|
||||
|
||||
fun getGalleryMediaForThread(threadId: Long, sorting: Sorting): Cursor {
|
||||
val query = if (FeatureFlags.instantVideoPlayback()) {
|
||||
@JvmOverloads
|
||||
fun getGalleryMediaForThread(threadId: Long, sorting: Sorting, limit: Int = 0): Cursor {
|
||||
var query = if (FeatureFlags.instantVideoPlayback()) {
|
||||
sorting.applyToQuery(applyEqualityOperator(threadId, GALLERY_MEDIA_QUERY_INCLUDING_TEMP_VIDEOS))
|
||||
} else {
|
||||
sorting.applyToQuery(applyEqualityOperator(threadId, GALLERY_MEDIA_QUERY))
|
||||
}
|
||||
val args = arrayOf(threadId.toString() + "")
|
||||
|
||||
if (limit > 0) {
|
||||
query = "$query LIMIT $limit"
|
||||
}
|
||||
|
||||
return readableDatabase.rawQuery(query, args)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user