提交 df6063fb 编写于 作者: M malenkov

7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed

Reviewed-by: anthony, serb
上级 ff89dde4
...@@ -181,6 +181,9 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment { ...@@ -181,6 +181,9 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
initDevices(); initDevices();
d = devices.get(mainDisplayID); d = devices.get(mainDisplayID);
if (d == null) {
throw new AWTError("no screen devices");
}
} }
return d; return d;
} }
......
...@@ -165,7 +165,11 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment ...@@ -165,7 +165,11 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
* Returns the default screen graphics device. * Returns the default screen graphics device.
*/ */
public GraphicsDevice getDefaultScreenDevice() { public GraphicsDevice getDefaultScreenDevice() {
return getScreenDevices()[0]; GraphicsDevice[] screens = getScreenDevices();
if (screens.length == 0) {
throw new AWTError("no screen devices");
}
return screens[0];
} }
/** /**
......
...@@ -200,7 +200,12 @@ public class X11GraphicsEnvironment ...@@ -200,7 +200,12 @@ public class X11GraphicsEnvironment
* Returns the default screen graphics device. * Returns the default screen graphics device.
*/ */
public GraphicsDevice getDefaultScreenDevice() { public GraphicsDevice getDefaultScreenDevice() {
return getScreenDevices()[getDefaultScreenNum()]; GraphicsDevice[] screens = getScreenDevices();
if (screens.length == 0) {
throw new AWTError("no screen devices");
}
int index = getDefaultScreenNum();
return screens[0 < index && index < screens.length ? index : 0];
} }
public boolean isDisplayLocal() { public boolean isDisplayLocal() {
......
...@@ -93,7 +93,12 @@ public class Win32GraphicsEnvironment ...@@ -93,7 +93,12 @@ public class Win32GraphicsEnvironment
protected native int getDefaultScreen(); protected native int getDefaultScreen();
public GraphicsDevice getDefaultScreenDevice() { public GraphicsDevice getDefaultScreenDevice() {
return getScreenDevices()[getDefaultScreen()]; GraphicsDevice[] screens = getScreenDevices();
if (screens.length == 0) {
throw new AWTError("no screen devices");
}
int index = getDefaultScreen();
return screens[0 < index && index < screens.length ? index : 0];
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册