Skip to content

Commit 2bc1b2e

Browse files
committed
Fix for null pointer exception in safe area
Fixed #3764
1 parent 3bd5ff3 commit 2bc1b2e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Ports/iOSPort/nativeSources/IOSNative.m

+16-12
Original file line numberDiff line numberDiff line change
@@ -8286,37 +8286,41 @@ JAVA_BOOLEAN com_codename1_impl_ios_IOSNative_nativeIsAlphaMaskSupportedGlobal__
82868286
JAVA_INT com_codename1_impl_ios_IOSNative_getDisplaySafeInsetLeft___R_int(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT instanceObject) {
82878287
if (@available(iOS 11.0, *)) {
82888288
UIWindow *window = UIApplication.sharedApplication.keyWindow;
8289-
return (JAVA_INT)(window.safeAreaInsets.left * scaleValue);
8290-
} else {
8291-
return 0;
8289+
if(window != nil && window.safeAreaInsets != nil) {
8290+
return (JAVA_INT)(window.safeAreaInsets.left * scaleValue);
8291+
}
82928292
}
8293+
return 0;
82938294
}
82948295

82958296
JAVA_INT com_codename1_impl_ios_IOSNative_getDisplaySafeInsetTop___R_int(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT instanceObject) {
82968297
if (@available(iOS 11.0, *)) {
82978298
UIWindow *window = UIApplication.sharedApplication.keyWindow;
8298-
return (JAVA_INT)(window.safeAreaInsets.top * scaleValue);
8299-
} else {
8300-
return 0;
8299+
if(window != nil && window.safeAreaInsets != nil) {
8300+
return (JAVA_INT)(window.safeAreaInsets.top * scaleValue);
8301+
}
83018302
}
8303+
return 0;
83028304
}
83038305

83048306
JAVA_INT com_codename1_impl_ios_IOSNative_getDisplaySafeInsetRight___R_int(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT instanceObject) {
83058307
if (@available(iOS 11.0, *)) {
83068308
UIWindow *window = UIApplication.sharedApplication.keyWindow;
8307-
return (JAVA_INT)(window.safeAreaInsets.right * scaleValue);
8308-
} else {
8309-
return 0;
8309+
if(window != nil && window.safeAreaInsets != nil) {
8310+
return (JAVA_INT)(window.safeAreaInsets.right * scaleValue);
8311+
}
83108312
}
8313+
return 0;
83118314
}
83128315

83138316
JAVA_INT com_codename1_impl_ios_IOSNative_getDisplaySafeInsetBottom___R_int(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT instanceObject) {
83148317
if (@available(iOS 11.0, *)) {
83158318
UIWindow *window = UIApplication.sharedApplication.keyWindow;
8316-
return (JAVA_INT)(window.safeAreaInsets.bottom * scaleValue);
8317-
} else {
8318-
return 0;
8319+
if(window != nil && window.safeAreaInsets != nil) {
8320+
return (JAVA_INT)(window.safeAreaInsets.bottom * scaleValue);
8321+
}
83198322
}
8323+
return 0;
83208324
}
83218325

83228326
JAVA_INT com_codename1_impl_ios_IOSNative_getDisplayWidth___R_int(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT instanceObject) {

0 commit comments

Comments
 (0)