From 94476a691045c92d01dbc15c718c77e10b7ef2d0 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Fri, 13 Mar 2020 02:02:30 -0500 Subject: [PATCH] Fix NPE on GUI during Windows Lock Screen (#3023) --- .../Make-the-GUI-graph-fancier.patch | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Spigot-Server-Patches/Make-the-GUI-graph-fancier.patch b/Spigot-Server-Patches/Make-the-GUI-graph-fancier.patch index 6443afb90..30686ddd2 100644 --- a/Spigot-Server-Patches/Make-the-GUI-graph-fancier.patch +++ b/Spigot-Server-Patches/Make-the-GUI-graph-fancier.patch @@ -236,7 +236,7 @@ index 000000000..e463a86a6 +} diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java b/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java new file mode 100644 -index 000000000..5892c4dc1 +index 000000000..c3e54da4a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java @@ -0,0 +0,0 @@ @@ -251,6 +251,7 @@ index 000000000..5892c4dc1 +import java.awt.Graphics; +import java.awt.MouseInfo; +import java.awt.Point; ++import java.awt.PointerInfo; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.SimpleDateFormat; @@ -312,13 +313,18 @@ index 000000000..5892c4dc1 + Runtime jvm = Runtime.getRuntime(); + DATA.add(new GraphData(jvm.totalMemory(), jvm.freeMemory(), jvm.maxMemory())); + -+ Point scr = MouseInfo.getPointerInfo().getLocation(); -+ Point loc = new Point(scr); -+ SwingUtilities.convertPointFromScreen(loc, this); -+ if (this.contains(loc)) { -+ ToolTipManager.sharedInstance().mouseMoved( -+ new MouseEvent(this, -1, System.currentTimeMillis(), 0, loc.x, loc.y, -+ scr.x, scr.y, 0, false, 0)); ++ PointerInfo pointerInfo = MouseInfo.getPointerInfo(); ++ if (pointerInfo != null) { ++ Point point = pointerInfo.getLocation(); ++ if (point != null) { ++ Point loc = new Point(point); ++ SwingUtilities.convertPointFromScreen(loc, this); ++ if (this.contains(loc)) { ++ ToolTipManager.sharedInstance().mouseMoved( ++ new MouseEvent(this, -1, System.currentTimeMillis(), 0, loc.x, loc.y, ++ point.x, point.y, 0, false, 0)); ++ } ++ } + } + + currentTick++;