提交 1161f5c6 编写于 作者: S serb

8028512: [macosx] Crash in full screen api if incorrect display mode is used

Reviewed-by: anthony, leonidr
上级 890ac343
...@@ -158,12 +158,12 @@ public final class CGraphicsDevice extends GraphicsDevice ...@@ -158,12 +158,12 @@ public final class CGraphicsDevice extends GraphicsDevice
boolean fsSupported = isFullScreenSupported(); boolean fsSupported = isFullScreenSupported();
if (fsSupported && old != null) { if (fsSupported && old != null) {
// restore original display mode and enter windowed mode. // enter windowed mode and restore original display mode
exitFullScreenExclusive(old);
if (originalMode != null) { if (originalMode != null) {
setDisplayMode(originalMode); setDisplayMode(originalMode);
originalMode = null; originalMode = null;
} }
exitFullScreenExclusive(old);
} }
super.setFullScreenWindow(w); super.setFullScreenWindow(w);
...@@ -227,14 +227,10 @@ public final class CGraphicsDevice extends GraphicsDevice ...@@ -227,14 +227,10 @@ public final class CGraphicsDevice extends GraphicsDevice
throw new IllegalArgumentException("Invalid display mode"); throw new IllegalArgumentException("Invalid display mode");
} }
if (!Objects.equals(dm, getDisplayMode())) { if (!Objects.equals(dm, getDisplayMode())) {
final Window w = getFullScreenWindow();
if (w != null) {
exitFullScreenExclusive(w);
}
nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(), nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(),
dm.getBitDepth(), dm.getRefreshRate()); dm.getBitDepth(), dm.getRefreshRate());
if (isFullScreenSupported() && w != null) { if (isFullScreenSupported() && getFullScreenWindow() != null) {
enterFullScreenExclusive(w); getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight());
} }
} }
} }
......
...@@ -1236,7 +1236,9 @@ JNF_COCOA_ENTER(env); ...@@ -1236,7 +1236,9 @@ JNF_COCOA_ENTER(env);
NSRect screenRect = [[nsWindow screen] frame]; NSRect screenRect = [[nsWindow screen] frame];
[nsWindow setFrame:screenRect display:YES]; [nsWindow setFrame:screenRect display:YES];
} else { } else {
[JNFException raise:env as:kRuntimeException reason:"Failed to enter full screen."]; [JNFException raise:[ThreadUtilities getJNIEnv]
as:kRuntimeException
reason:"Failed to enter full screen."];
} }
}]; }];
...@@ -1261,7 +1263,9 @@ JNF_COCOA_ENTER(env); ...@@ -1261,7 +1263,9 @@ JNF_COCOA_ENTER(env);
// GraphicsDevice takes care of restoring pre full screen bounds // GraphicsDevice takes care of restoring pre full screen bounds
} else { } else {
[JNFException raise:env as:kRuntimeException reason:"Failed to exit full screen."]; [JNFException raise:[ThreadUtilities getJNIEnv]
as:kRuntimeException
reason:"Failed to exit full screen."];
} }
}]; }];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册