mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-17 04:20:00 +03:00
Ensure clearWith lambda is deleting all the list item, else we will get an infinite loop. This specific error will help to figure out what is happening.
This commit is contained in:
parent
69920a6e46
commit
9866bfefed
1 changed files with 4 additions and 0 deletions
|
@ -30,7 +30,11 @@ internal fun RealmObject.assertIsManaged() {
|
|||
*/
|
||||
internal fun <T> RealmList<T>.clearWith(delete: (T) -> Unit) {
|
||||
while (!isEmpty()) {
|
||||
val previousSize = size
|
||||
first()?.let { delete.invoke(it) }
|
||||
if (previousSize != size + 1) {
|
||||
error("`clearWith` MUST delete all elements of the RealmList")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue