From 7bda2d95d296628cdbe54486ad2909a49adf0410 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Mon, 15 Jan 2024 19:57:33 +0400 Subject: [PATCH] GUI: improved stability of popup hint window (fixed game freeze in some use cases, fixes #11595) --- .../mage/client/components/MageEditorPane.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/components/MageEditorPane.java b/Mage.Client/src/main/java/mage/client/components/MageEditorPane.java index 865499fc0ca..c10c66403a0 100644 --- a/Mage.Client/src/main/java/mage/client/components/MageEditorPane.java +++ b/Mage.Client/src/main/java/mage/client/components/MageEditorPane.java @@ -59,7 +59,7 @@ public class MageEditorPane extends JEditorPane { } public void cleanUp() { - resetCursor(); + setCursorToDefault(); } private void addHyperlinkHandlers() { @@ -171,17 +171,23 @@ public class MageEditorPane extends JEditorPane { @Override public void mouseExited(MouseEvent e) { cardInfo.onMouseExited(); - resetCursor(); + setCursorToDefault(); } }); } - private void resetCursor() { - SwingUtilities.windowForComponent(this).setCursor(Cursor.getDefaultCursor()); + private void setCursorToDefault() { + Window parent = SwingUtilities.windowForComponent(this); + if (parent != null) { + parent.setCursor(Cursor.getDefaultCursor()); + } } private void setCursorToHand() { - SwingUtilities.windowForComponent(this).setCursor(new Cursor(Cursor.HAND_CURSOR)); + Window parent = SwingUtilities.windowForComponent(this); + if (parent != null) { + parent.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } } private void urlHighlightEnable(Element hyperlinkElement) { @@ -197,7 +203,7 @@ public class MageEditorPane extends JEditorPane { changeUrlTextDecoration(lastUrlElementEntered, "none"); lastUrlElementEntered = null; } - resetCursor(); + setCursorToDefault(); } private void changeUrlTextDecoration(Element el, String decoration) {