From 59fb950c791acb1c6e944056f28dc199517d1182 Mon Sep 17 00:00:00 2001 From: adamopolous Date: Wed, 17 Apr 2019 12:29:47 -0400 Subject: [PATCH] GT-2801: fixed analysis options bug causing apply button to not be activated --- .../plugin/core/analysis/AnalysisPanel.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java index a21fd902b4..700ae2943b 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java @@ -33,6 +33,7 @@ import org.apache.commons.collections4.CollectionUtils; import docking.options.editor.GenericOptionsComponent; import docking.widgets.OptionDialog; import docking.widgets.table.*; +import ghidra.GhidraOptions; import ghidra.app.services.Analyzer; import ghidra.framework.options.*; import ghidra.program.model.listing.Program; @@ -465,20 +466,27 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener { @Override public void propertyChange(PropertyChangeEvent evt) { - checkForDifferences(); + if (checkForDifferences()) { + propertyChangeListener.propertyChange( + new PropertyChangeEvent(this, GhidraOptions.APPLY_ENABLED, null, Boolean.TRUE)); + } } private boolean checkForDifferences() { + boolean changes = false; for (int i = 0; i < analyzerNames.size(); ++i) { String analyzerName = analyzerNames.get(i); boolean currEnabled = analyzerEnablement.get(i); boolean origEnabled = analysisOptions.getBoolean(analyzerName, false); if (currEnabled != origEnabled) { + changes = true; propertyChangeListener.propertyChange( new PropertyChangeEvent(this, analyzerName, origEnabled, currEnabled)); - return true; } } + if (changes) { + return true; + } for (EditorState info : editorList) { if (info.isValueChanged()) { return true; @@ -602,21 +610,18 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener { */ public void updateOptionForAllPrograms(String analyzerName, boolean enabled) { for (Program program : programs) { - + + // Check to make sure we're only handling events that relate to analyzers. If we + // receive something else (eg: "analyze.apply") ignore it. + Options options = program.getOptions(Program.ANALYSIS_PROPERTIES); + if (!options.getOptionNames().contains(analyzerName)) { + continue; + } + boolean commit = false; - int id = program.startTransaction("Setting analysis property"); + int id = program.startTransaction("Setting analysis property " + analyzerName); try { - Options options = program.getOptions(Program.ANALYSIS_PROPERTIES); - - // Sanity check to make sure that the analyzer is appropriate for - // this program. This should always be the case but it doesn't - // hurt to check. - if (!options.getOptionNames().contains(analyzerName)) { - continue; - } - options.setBoolean(analyzerName, enabled); - commit = true; } finally { @@ -624,5 +629,4 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener { } } } - }