Skip to content

Commit 8b19ea4

Browse files
committed
Add null window check
1 parent a2cdaa8 commit 8b19ea4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/backhandler/UIKitBackGestureDispatcher.kt

+7-5
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ internal class UIKitBackGestureDispatcher(
9494
fun onDidMoveToWindow(window: UIWindow?, composeRootView: UIView) {
9595
if (enableBackGesture) {
9696
removeGestureListeners()
97-
var view: UIView = composeRootView
98-
while (view.superview != window) {
99-
view = requireNotNull(view.superview) {
100-
"Window is not null, but superview is null for ${view.debugDescription}"
97+
if (window != null) {
98+
var view: UIView = composeRootView
99+
while (view.superview != window) {
100+
view = requireNotNull(view.superview) {
101+
"Window is not null, but superview is null for ${view.debugDescription}"
102+
}
101103
}
104+
addGestureListeners(view)
102105
}
103-
addGestureListeners(view)
104106
}
105107
}
106108

0 commit comments

Comments
 (0)