Fixed potential NPE from Cursor.getCapabilities()
This commit is contained in:
parent
d4d39bf869
commit
d396992cc5
|
@ -141,7 +141,10 @@ public class Cursor {
|
||||||
* @return A bit mask with native cursor capabilities.
|
* @return A bit mask with native cursor capabilities.
|
||||||
*/
|
*/
|
||||||
public static int getCapabilities() {
|
public static int getCapabilities() {
|
||||||
|
if (Mouse.getImplementation() != null)
|
||||||
return Mouse.getImplementation().getNativeCursorCapabilities();
|
return Mouse.getImplementation().getNativeCursorCapabilities();
|
||||||
|
else
|
||||||
|
return Mouse.createImplementation().getNativeCursorCapabilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -307,6 +307,8 @@ public class Keyboard {
|
||||||
* @throws LWJGLException if the keyboard could not be created for any reason
|
* @throws LWJGLException if the keyboard could not be created for any reason
|
||||||
*/
|
*/
|
||||||
public static void create() throws LWJGLException {
|
public static void create() throws LWJGLException {
|
||||||
|
if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
|
||||||
|
|
||||||
create(Mouse.createImplementation());
|
create(Mouse.createImplementation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,8 +225,6 @@ public class Mouse {
|
||||||
}
|
}
|
||||||
|
|
||||||
static InputImplementation createImplementation() {
|
static InputImplementation createImplementation() {
|
||||||
if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
|
|
||||||
|
|
||||||
/* Use reflection since we can't make Display.getImplementation
|
/* Use reflection since we can't make Display.getImplementation
|
||||||
* public
|
* public
|
||||||
*/
|
*/
|
||||||
|
@ -278,6 +276,8 @@ public class Mouse {
|
||||||
* @throws LWJGLException if the mouse could not be created for any reason
|
* @throws LWJGLException if the mouse could not be created for any reason
|
||||||
*/
|
*/
|
||||||
public static void create() throws LWJGLException {
|
public static void create() throws LWJGLException {
|
||||||
|
if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
|
||||||
|
|
||||||
create(createImplementation());
|
create(createImplementation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue