changeset 8830:c1bbf2d0bc80

8028512: [macosx] Crash in full screen api if incorrect display mode is used Reviewed-by: anthony, leonidr
author serb
date Fri, 22 Nov 2013 17:02:49 +0400
parents 876c81f7f44c
children e3df535c613f
files src/macosx/classes/sun/awt/CGraphicsDevice.java src/macosx/native/sun/awt/AWTWindow.m
diffstat 2 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/awt/CGraphicsDevice.java	Fri Nov 22 15:48:22 2013 +0400
+++ b/src/macosx/classes/sun/awt/CGraphicsDevice.java	Fri Nov 22 17:02:49 2013 +0400
@@ -158,12 +158,12 @@
         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 @@
             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());
             }
         }
     }
--- a/src/macosx/native/sun/awt/AWTWindow.m	Fri Nov 22 15:48:22 2013 +0400
+++ b/src/macosx/native/sun/awt/AWTWindow.m	Fri Nov 22 17:02:49 2013 +0400
@@ -1236,7 +1236,9 @@
             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 @@
 
             // 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."];
         }
     }];