From 05472d1222d623ee775716a272db99a31c0fa480 Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Tue, 23 Apr 2019 14:30:18 -0400 Subject: [PATCH] GT-2830 - Help - fixed NPE when navigating help UI --- .../docking/help/CustomFavoritesView.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Ghidra/Framework/Docking/src/main/java/docking/help/CustomFavoritesView.java b/Ghidra/Framework/Docking/src/main/java/docking/help/CustomFavoritesView.java index bcc6e0b5fe..425f286955 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/help/CustomFavoritesView.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/help/CustomFavoritesView.java @@ -18,6 +18,7 @@ package docking.help; import java.awt.Component; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.beans.PropertyChangeListener; import java.net.MalformedURLException; import java.net.URL; import java.util.Hashtable; @@ -73,6 +74,8 @@ public class CustomFavoritesView extends FavoritesView { class CustomFavoritesNavigatorUI extends BasicFavoritesNavigatorUI { + private PropertyChangeListener titleListener; + CustomFavoritesNavigatorUI(JHelpFavoritesNavigator b) { super(b); } @@ -94,7 +97,7 @@ public class CustomFavoritesView extends FavoritesView { // Note: add a listener to fix the bug described in 'idChanged()' below HelpModel model = favorites.getModel(); - model.addPropertyChangeListener(e -> { + titleListener = e -> { if (lastIdEvent == null) { return; @@ -109,7 +112,20 @@ public class CustomFavoritesView extends FavoritesView { if (!currentTitle.equals(lastTitle)) { resendNewEventWithFixedTitle(lastIdEvent, currentTitle); } - }); + }; + + model.addPropertyChangeListener(titleListener); + } + + @Override + public void uninstallUI(JComponent c) { + + HelpModel model = favorites.getModel(); + if (model != null) { + model.removePropertyChangeListener(titleListener); + } + + super.uninstallUI(c); } private void resendNewEventWithFixedTitle(HelpModelEvent originalEvent, String title) {