mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-23 11:58:03 +00:00
7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
Reviewed-by: anthony, serb
This commit is contained in:
parent
dd224c8deb
commit
e37d16f11b
@ -181,6 +181,9 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
initDevices();
|
||||
|
||||
d = devices.get(mainDisplayID);
|
||||
if (d == null) {
|
||||
throw new AWTError("no screen devices");
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
@ -165,7 +165,11 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
* Returns the default screen graphics device.
|
||||
*/
|
||||
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
|
||||
* Returns the default screen graphics device.
|
||||
*/
|
||||
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() {
|
||||
|
||||
@ -93,7 +93,12 @@ public class Win32GraphicsEnvironment
|
||||
protected native int getDefaultScreen();
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user