Skip to content

Commit b262860

Browse files
committed
Clean POSModalManager resources when POS is closed
POSModalManager creates memory leaks by holding closures that deeper in the stack hold POSModalManager, creating reference cycles. We need to manually break them. We already cal reset() when view disappears. However, it's not called when POS is closed. Not cleaning POSModalManager results in all POS resources, incuding aggregate models and services duplicated.
1 parent 6a412b9 commit b262860

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

WooCommerce/Classes/POS/Presentation/PointOfSaleEntryPointView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct PointOfSaleEntryPointView: View {
3030
}
3131
.onDisappear {
3232
onPointOfSaleModeActiveStateChange(false)
33+
posModalManager.onDisappear()
3334
}
3435
}
3536
}

WooCommerce/Classes/POS/Presentation/Reusable Views/POSModalManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class POSModalManager: ObservableObject {
2626
allowsInteractiveDismissal = allowed
2727
}
2828

29+
func onDisappear() {
30+
reset()
31+
}
32+
2933
private func reset() {
3034
onDismiss = nil
3135
allowsInteractiveDismissal = true

0 commit comments

Comments
 (0)