修复切换书籍或者章节时的断言崩溃问题。看漫画容易复现。

clearCache增加保护。因漫画图片loadContent耗时较长,此时其他操作启用新的协程loadContent容易撞到clear和setCache干扰导致signal 11崩溃。
pull/883/head
hoodie13 4 years ago
parent 4102b12efd
commit 4904dd117c
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt

@ -61,6 +61,7 @@ object ImageProvider {
} }
} }
@Synchronized
fun clearAllCache() { fun clearAllCache() {
cache.forEach { indexCache -> cache.forEach { indexCache ->
indexCache.value.forEach { indexCache.value.forEach {
@ -70,6 +71,7 @@ object ImageProvider {
cache.clear() cache.clear()
} }
@Synchronized
fun clearOut(chapterIndex: Int) { fun clearOut(chapterIndex: Int) {
cache.forEach { indexCache -> cache.forEach { indexCache ->
if (indexCache.key !in chapterIndex - 1..chapterIndex + 1) { if (indexCache.key !in chapterIndex - 1..chapterIndex + 1) {

Loading…
Cancel
Save