Skip to content

Commit

Permalink
Another workaround for NPE in safe area on iOS
Browse files Browse the repository at this point in the history
Fixed #3764 again. I'm guessing this is caused because of a threading issue in which case the issue can be ignored and refreshed later on. So the NPE is swallowed.
  • Loading branch information
shai-almog committed Nov 21, 2023
1 parent 56959e1 commit a8e1bd6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Ports/iOSPort/src/com/codename1/impl/ios/IOSImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,15 @@ public Rectangle getDisplaySafeArea(Rectangle rect) {
if (rect == null) {
rect = new Rectangle();
}
int x = nativeInstance.getDisplaySafeInsetLeft();
int y = nativeInstance.getDisplaySafeInsetTop();
int w = getDisplayWidth() - nativeInstance.getDisplaySafeInsetRight() - x;
int h = getDisplayHeight() - nativeInstance.getDisplaySafeInsetBottom() - y;
rect.setBounds(x, y, w, h);
try {
int x = nativeInstance.getDisplaySafeInsetLeft();
int y = nativeInstance.getDisplaySafeInsetTop();
int w = getDisplayWidth() - nativeInstance.getDisplaySafeInsetRight() - x;
int h = getDisplayHeight() - nativeInstance.getDisplaySafeInsetBottom() - y;
rect.setBounds(x, y, w, h);
} catch (NullPointerException err) {
Log.p("Invalid bounds in getDisplaySafeArea, if this message repeats frequently please let us know...");
}

return rect;
}
Expand Down

0 comments on commit a8e1bd6

Please sign in to comment.