fixed incorrect index counting

This commit is contained in:
ramollia
2025-12-04 18:28:25 +01:00
parent 75c4e55da6
commit a7b9484aa4

View File

@@ -60,7 +60,7 @@ public abstract class ViewWidget extends StackWidget {
} }
public void removeIndexFromPreviousChain(int index) { public void removeIndexFromPreviousChain(int index) {
ViewWidget view = previous; ViewWidget view = this;
while (index > 0 && view != null) { while (index > 0 && view != null) {
index--; index--;
@@ -76,15 +76,18 @@ public abstract class ViewWidget extends StackWidget {
} }
public void removeViewFromPreviousChain(ViewWidget view) { public void removeViewFromPreviousChain(ViewWidget view) {
ViewWidget prev = previous;
int index = 0; int index = 0;
while (previous != null) { while (prev != null) {
index++; index++;
if (previous == view) { if (prev == view) {
removeIndexFromPreviousChain(index); removeIndexFromPreviousChain(index);
break; break;
} }
prev = prev.previous;
} }
} }