From: <eli...@us...> - 2008-04-10 20:15:52
|
Revision: 3001 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3001&view=rev Author: elias_naur Date: 2008-04-10 13:14:15 -0700 (Thu, 10 Apr 2008) Log Message: ----------- Mac OS X: Fixed potential NPE in AWTUtil.getPointerLocation Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2008-04-09 23:40:18 UTC (rev 3000) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2008-04-10 20:14:15 UTC (rev 3001) @@ -39,6 +39,7 @@ import java.awt.Cursor; import java.awt.Dimension; import java.awt.GraphicsDevice; +import java.awt.GraphicsConfiguration; import java.awt.IllegalComponentStateException; import java.awt.Point; import java.awt.Robot; @@ -115,12 +116,15 @@ final Method getLocation_method = PointerInfo_class.getMethod("getLocation", null); return (Point)AccessController.doPrivileged(new PrivilegedExceptionAction() { public final Object run() throws Exception { - Object pointer_info = getPointerInfo_method.invoke(null, null); - GraphicsDevice device = (GraphicsDevice)getDevice_method.invoke(pointer_info, null); - if (device == component.getGraphicsConfiguration().getDevice()) { - return (Point)getLocation_method.invoke(pointer_info, null); - } else - return null; + GraphicsConfiguration config = component.getGraphicsConfiguration(); + if (config != null) { + Object pointer_info = getPointerInfo_method.invoke(null, null); + GraphicsDevice device = (GraphicsDevice)getDevice_method.invoke(pointer_info, null); + if (device == config.getDevice()) { + return (Point)getLocation_method.invoke(pointer_info, null); + } + } + return null; } }); } catch (PrivilegedActionException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |