Skip to content

Commit

Permalink
fix concurrent modification
Browse files Browse the repository at this point in the history
  • Loading branch information
hg42 committed Feb 5, 2023
1 parent ace6eae commit 893b033
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,12 @@ object IconCache {
}

fun dropAllButUsed(pkgs: List<Package>) {
val used = pkgs.map { it.iconData }
beginNanoTimer("limitIconCache")
val keys = synchronized(painterCache) { painterCache.keys }
(keys - pkgs.map { it.iconData }).forEach {
(keys - used).forEach {
if (it !is Int) {
IconCache.removeIcon(it)
removeIcon(it)
}
}
endNanoTimer("limitIconCache")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MainViewModel(
//val pkgs = p.toPackageList(appContext, emptyList(), b)
val pkgs = p.toPackageList(appContext, emptyList(), getBackups())

IconCache.dropAllButUsed(pkgs)
IconCache.dropAllButUsed(pkgs.drop(0))

traceFlows { "***** packages ->> ${pkgs.size}" }
pkgs
Expand Down

0 comments on commit 893b033

Please sign in to comment.