Skip to content

Commit

Permalink
Fix ConcurrentModificationException when manipulating backstack durin…
Browse files Browse the repository at this point in the history
…g instantiation
  • Loading branch information
EricKuck committed May 9, 2023
1 parent f69fab6 commit 4d4d8bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions conductor/src/main/java/com/bluelinelabs/conductor/Backstack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ internal class Backstack : Iterable<RouterTransaction> {

fun root(): RouterTransaction? = backstack.lastOrNull()

override fun iterator(): MutableIterator<RouterTransaction> {
return backstack.iterator()
}
override fun iterator(): Iterator<RouterTransaction> = backstack.toTypedArray().iterator()

fun reverseIterator(): Iterator<RouterTransaction> = backstack.reversed().iterator()

fun reverseIterator(): Iterator<RouterTransaction> = backstack.descendingIterator()
fun remove(transaction: RouterTransaction) = backstack.remove(transaction)

fun popTo(transaction: RouterTransaction): List<RouterTransaction> {
if (transaction in backstack) {
Expand Down Expand Up @@ -99,4 +99,4 @@ internal class Backstack : Iterable<RouterTransaction> {
companion object {
private const val KEY_ENTRIES = "Backstack.entries"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public boolean popController(@NonNull Controller controller) {
RouterTransaction transaction = iterator.next();
if (transaction.controller() == controller) {
trackDestroyingController(transaction);
iterator.remove();
backstack.remove(transaction);
removedTransaction = transaction;
} else if (removedTransaction != null) {
if (needsNextTransactionAttach && !transaction.controller().isAttached()) {
Expand Down

0 comments on commit 4d4d8bf

Please sign in to comment.