diff options
author | Sven Gothel <[email protected]> | 2015-08-05 13:44:11 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-08-05 13:44:11 +0200 |
commit | 4ff4f735c421ef343a8c447fa699c01444bd5e9b (patch) | |
tree | 12431a179c345b0b89dc65e57a8e78ac4e2b1fc5 /src/newt | |
parent | da1a4cc5bc4a7fda0605709b61a63564b9070378 (diff) |
Bug 1183: Handle NULL return values for native RandR13 calls, which suppose to return 'int[]'
Certain native RandR13 functions shall return 'int[]',
but will bail out early in case of an error or lack of resources.
The latter is true for getMonitorDeviceIds(..)
where 'XRRScreenResources->ncrtc <= 0', causing return value NULL.
This patch handles the NULL return values,
however, the root cause of having 'XRRScreenResources->ncrtc <= 0'
_occasionally_ lies within the Raspi X11 driver I am afraid?!
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/x11/RandR13.java | 1 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java | 18 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index 95bff0118..bd3c7925e 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -275,7 +275,6 @@ class RandR13 implements RandR { private static native int[] getAvailableRotations0(long monitorInfo); private static native int[] getMonitorViewport0(long monitorInfo); - private static native int[] getMonitorCurrentMode0(long monitorInfo); private static native int[] getMonitorMode0(long screenResources, int mode_index); private static native int[] getMonitorCurrentMode0(long screenResources, long monitorInfo); diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 517d229b7..873ee3f53 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -121,7 +121,7 @@ public class ScreenDriver extends ScreenImpl { if( rAndR.beginInitialQuery(device.getHandle(), this) ) { try { final int[] crt_ids = rAndR.getMonitorDeviceIds(device.getHandle(), this); - final int crtCount = crt_ids.length; + final int crtCount = null != crt_ids ? crt_ids.length : 0; // Gather all available rotations final ArrayHashSet<Integer> availableRotations = new ArrayHashSet<Integer>(false, ArrayHashSet.DEFAULT_INITIAL_CAPACITY, ArrayHashSet.DEFAULT_LOAD_FACTOR); @@ -173,9 +173,13 @@ public class ScreenDriver extends ScreenImpl { device.lock(); try { final int[] viewportProps = rAndR.getMonitorDeviceViewport(device.getHandle(), this, monitor.getId()); - viewportPU.set(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); - viewportWU.set(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); // equal window-units and pixel-units - return true; + if( null != viewportProps ) { + viewportPU.set(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); + viewportWU.set(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); // equal window-units and pixel-units + return true; + } else { + return false; + } } finally { device.unlock(); } @@ -189,7 +193,11 @@ public class ScreenDriver extends ScreenImpl { @Override public MonitorMode run(final long dpy) { final int[] currentModeProps = rAndR.getCurrentMonitorModeProps(dpy, ScreenDriver.this, monitor.getId()); - return MonitorModeProps.streamInMonitorMode(null, null, currentModeProps, 0); + if( null != currentModeProps ) { + return MonitorModeProps.streamInMonitorMode(null, null, currentModeProps, 0); + } else { + return null; + } } } ); } |