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

Reviewed-by: anthony, leonidr
This commit is contained in:
Sergey Bylokhov 2013-11-22 17:02:49 +04:00
parent a91ac39f00
commit b7cad91e1f
2 changed files with 11 additions and 11 deletions

View File

@ -158,12 +158,12 @@ public final class CGraphicsDevice extends GraphicsDevice
boolean fsSupported = isFullScreenSupported();
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) {
setDisplayMode(originalMode);
originalMode = null;
}
exitFullScreenExclusive(old);
}
super.setFullScreenWindow(w);
@ -227,14 +227,10 @@ public final class CGraphicsDevice extends GraphicsDevice
throw new IllegalArgumentException("Invalid display mode");
}
if (!Objects.equals(dm, getDisplayMode())) {
final Window w = getFullScreenWindow();
if (w != null) {
exitFullScreenExclusive(w);
}
nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(),
dm.getBitDepth(), dm.getRefreshRate());
if (isFullScreenSupported() && w != null) {
enterFullScreenExclusive(w);
dm.getBitDepth(), dm.getRefreshRate());
if (isFullScreenSupported() && getFullScreenWindow() != null) {
getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight());
}
}
}

View File

@ -1236,7 +1236,9 @@ JNF_COCOA_ENTER(env);
NSRect screenRect = [[nsWindow screen] frame];
[nsWindow setFrame:screenRect display:YES];
} 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);
// GraphicsDevice takes care of restoring pre full screen bounds
} else {
[JNFException raise:env as:kRuntimeException reason:"Failed to exit full screen."];
[JNFException raise:[ThreadUtilities getJNIEnv]
as:kRuntimeException
reason:"Failed to exit full screen."];
}
}];