Skip to content

Ghidra is a software reverse engineering (SRE) framework

Updated the help window to not preserve the previous location on a new request for the same page

dragonmacheref7c79f0c0f4
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java
index bef8190a3e..75c6cadbf9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java
@@ -573,7 +573,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
/**
* Returns true if there is a {@link CodeUnit} for the address
- * wrapped by this info. If not, then we do not have a valid addreess.
+ * wrapped by this info. If not, then we do not have a valid address.
*
* @return true if there is a {@link CodeUnit} for the address
* wrapped by this info.
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/help/DockingHelpBroker.java b/Ghidra/Framework/Docking/src/main/java/docking/help/DockingHelpBroker.java
index 6f8f54afa5..3e865b9f7e 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/help/DockingHelpBroker.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/help/DockingHelpBroker.java
@@ -142,7 +142,7 @@ public class DockingHelpBroker extends GHelpBroker {
@Override
public void actionPerformed(ActionEvent e) {
- reloadHelpPage(getCurrentURL());
+ reloadHelpPage(getCurrentURL(), true);
}
};
toolbar.add(new JButton(refreshAction));
@@ -150,8 +150,8 @@ public class DockingHelpBroker extends GHelpBroker {
}
@Override // opened access
- protected void reloadHelpPage(URL url) {
- super.reloadHelpPage(url);
+ protected void reloadHelpPage(URL url, boolean preserveLocation) {
+ super.reloadHelpPage(url, preserveLocation);
}
//=================================================================================================
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.java b/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.java
index a981540e66..86898f8bc8 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -462,7 +462,7 @@ public class HelpManager implements HelpService {
// an invokeLater() will work as long as the model loading is
// relatively quick.
//
- SystemUtilities.runSwingLater(() -> displayHelp(help, owner));
+ Swing.runLater(() -> displayHelp(help, owner));
return;
}
@@ -596,7 +596,10 @@ public class HelpManager implements HelpService {
return;
}
- ((DockingHelpBroker) mainHB).reloadHelpPage(validateUrl(helpURL));
+ // Let the URL dictate where the page scrolls to. If we do not do this, then there is an
+ // odd effect of having the page load and then jump to a previous location.
+ boolean preserveLocation = false;
+ ((DockingHelpBroker) mainHB).reloadHelpPage(validateUrl(helpURL), preserveLocation);
}
private URL getURLForID(ID ID) {
diff --git a/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java b/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java
index d8ea22fbcb..7ffdb472d4 100644
--- a/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java
+++ b/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -85,14 +85,14 @@ public class GHelpBroker extends DefaultHelpBroker {
}
/* Perform some shenanigans to force Java Help to reload the given URL */
- protected void reloadHelpPage(URL url) {
+ protected void reloadHelpPage(URL url, boolean preserveLocation) {
clearContentViewer();
showNavigationAid(url);
try {
// Page loading is asynchronous. Listen for the page to be loaded and then restore the
// users current view state.
- htmlEditorPane.addPropertyChangeListener(new PageLocationUpdater());
+ htmlEditorPane.addPropertyChangeListener(new PageLocationUpdater(preserveLocation));
htmlEditorPane.setPage(url);
}
catch (IOException e) {
@@ -102,7 +102,7 @@ public class GHelpBroker extends DefaultHelpBroker {
}
private void reloadHelpPage() {
- reloadHelpPage(getCurrentURL());
+ reloadHelpPage(getCurrentURL(), true);
}
public void reload() {
@@ -378,8 +378,10 @@ public class GHelpBroker extends DefaultHelpBroker {
private URL url;
private int caretPosition;
private Rectangle viewPosition;
+ private boolean preserveLocation;
- PageLocationUpdater() {
+ PageLocationUpdater(boolean preserveLocation) {
+ this.preserveLocation = preserveLocation;
url = getCurrentURL();
caretPosition = htmlEditorPane.getCaretPosition();
viewPosition = htmlEditorPane.getVisibleRect();
@@ -399,6 +401,10 @@ public class GHelpBroker extends DefaultHelpBroker {
return; // new page loaded; ignore
}
+ if (!preserveLocation) {
+ return;
+ }
+
htmlEditorPane.setCaretPosition(caretPosition);
// not sure why this needs to be done later, but setting the caret seems to trigger a
// view updated, so try to run after that