From b49806c499d259af259bb28c04f74887f288d801 Mon Sep 17 00:00:00 2001 From: 4RH1T3CT0R7 Date: Wed, 4 Feb 2026 17:16:39 +0300 Subject: [PATCH] Handle null checks for parent and active editor in popup initialization --- .../contributions/ContributionsSelfCheck.java | 3 ++ .../cc/arduino/view/NotificationPopup.java | 39 +++++++++++-------- app/src/processing/app/NewBoardListener.java | 6 ++- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/app/src/cc/arduino/contributions/ContributionsSelfCheck.java b/app/src/cc/arduino/contributions/ContributionsSelfCheck.java index 50e5e8617ea..04c01c876ba 100644 --- a/app/src/cc/arduino/contributions/ContributionsSelfCheck.java +++ b/app/src/cc/arduino/contributions/ContributionsSelfCheck.java @@ -125,6 +125,9 @@ public void run() { SwingUtilities.invokeLater(() -> { Editor ed = base.getActiveEditor(); + if (ed == null) { + return; + } boolean accessibleIde = PreferencesData.getBoolean("ide.accessible"); if (accessibleIde) { notificationPopup = new NotificationPopup(ed, hyperlinkListener, text, false, this, button1Name, button2Name); diff --git a/app/src/cc/arduino/view/NotificationPopup.java b/app/src/cc/arduino/view/NotificationPopup.java index 2de079c8525..c085ee5ee87 100644 --- a/app/src/cc/arduino/view/NotificationPopup.java +++ b/app/src/cc/arduino/view/NotificationPopup.java @@ -220,27 +220,32 @@ public void mouseClicked(MouseEvent e) { pack(); updateLocation(parent); - ComponentAdapter parentMovedListener = new ComponentAdapter() { - @Override - public void componentMoved(ComponentEvent e) { - updateLocation(parent); - } + if (parent != null) { + ComponentAdapter parentMovedListener = new ComponentAdapter() { + @Override + public void componentMoved(ComponentEvent e) { + updateLocation(parent); + } - @Override - public void componentResized(ComponentEvent e) { - updateLocation(parent); - } - }; - parent.addComponentListener(parentMovedListener); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - parent.removeComponentListener(parentMovedListener); - } - }); + @Override + public void componentResized(ComponentEvent e) { + updateLocation(parent); + } + }; + parent.addComponentListener(parentMovedListener); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + parent.removeComponentListener(parentMovedListener); + } + }); + } } private void updateLocation(Frame parent) { + if (parent == null) { + return; + } Point parentLocation = parent.getLocation(); int parentX = Double.valueOf(parentLocation.getX()).intValue(); diff --git a/app/src/processing/app/NewBoardListener.java b/app/src/processing/app/NewBoardListener.java index 7e0fe61d708..4b532c64aba 100644 --- a/app/src/processing/app/NewBoardListener.java +++ b/app/src/processing/app/NewBoardListener.java @@ -73,9 +73,11 @@ public void checkForNewBoardAttached() { } SwingUtilities.invokeLater(() -> { - ed = base.getActiveEditor(); - NotificationPopup notificationPopup = new NotificationPopup(ed, + if (ed == null) { + return; + } + NotificationPopup notificationPopup = new NotificationPopup(ed, new UpdatableBoardsLibsFakeURLsHandler(base), newBoardManagerLink, false); if (ed.isFocused()) {