mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-09 22:17:55 -05:00
GP-6249 fix swing deadlock in Search For Encoded Strings dialog
Problem would happen if dialog was trying to close itself at the same time as kicking off a translate. Also fix problem with created items coming back into the list after changing a filter option.
This commit is contained in:
@@ -762,8 +762,10 @@ public class EncodedStringsDialog extends DialogComponentProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createStringsHelper(TaskMonitor monitor) {
|
private void createStringsHelper(Runnable followupAction, TaskMonitor monitor) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
List<ProgramLocation> newStrings = new ArrayList<>();
|
||||||
|
|
||||||
setStatusText("Creating strings...");
|
setStatusText("Creating strings...");
|
||||||
int txId = program.startTransaction("Create Strings");
|
int txId = program.startTransaction("Create Strings");
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
@@ -780,7 +782,6 @@ public class EncodedStringsDialog extends DialogComponentProvider {
|
|||||||
monitor.initialize(stringsToCreate.size());
|
monitor.initialize(stringsToCreate.size());
|
||||||
monitor.setMessage("Creating strings...");
|
monitor.setMessage("Creating strings...");
|
||||||
Settings settings = currentOptions.settings();
|
Settings settings = currentOptions.settings();
|
||||||
List<ProgramLocation> newStrings = new ArrayList<>();
|
|
||||||
for (EncodedStringsRow row : stringsToCreate) {
|
for (EncodedStringsRow row : stringsToCreate) {
|
||||||
if (monitor.isCancelled()) {
|
if (monitor.isCancelled()) {
|
||||||
break;
|
break;
|
||||||
@@ -811,26 +812,28 @@ public class EncodedStringsDialog extends DialogComponentProvider {
|
|||||||
// See table listener for the other end of this
|
// See table listener for the other end of this
|
||||||
rowToSelect.set(selectedRowNums[0]);
|
rowToSelect.set(selectedRowNums[0]);
|
||||||
}
|
}
|
||||||
StringTranslationService sts = getSelectedStringTranslationService(true);
|
|
||||||
if (sts != null) {
|
|
||||||
Swing.runLater(
|
|
||||||
() -> sts.translate(program, newStrings, new TranslateOptions(true)));
|
|
||||||
}
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
program.endTransaction(txId, success);
|
program.endTransaction(txId, success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringTranslationService sts = getSelectedStringTranslationService(true);
|
||||||
|
|
||||||
|
if (followupAction != null) {
|
||||||
|
followupAction.run();
|
||||||
|
}
|
||||||
|
if (success && sts != null && !newStrings.isEmpty()) {
|
||||||
|
sts.translate(program, newStrings, new TranslateOptions(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createStrings(TaskMonitor monitor) {
|
private void createStrings(TaskMonitor monitor) {
|
||||||
createStringsHelper(monitor);
|
createStringsHelper(() -> setActionItemEnablement(true), monitor);
|
||||||
Swing.runLater(() -> setActionItemEnablement(true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createStringsAndClose(TaskMonitor monitor) {
|
private void createStringsAndClose(TaskMonitor monitor) {
|
||||||
createStringsHelper(monitor);
|
createStringsHelper(this::close, monitor);
|
||||||
Swing.runLater(this::close);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCreateButtonInfo(int rowCount, int selectedRowCount) {
|
private void setCreateButtonInfo(int rowCount, int selectedRowCount) {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -190,12 +190,20 @@ class EncodedStringsTableModel extends AddressBasedTableModel<EncodedStringsRow>
|
|||||||
for (EncodedStringsRow row : rows) {
|
for (EncodedStringsRow row : rows) {
|
||||||
removeObject(row);
|
removeObject(row);
|
||||||
}
|
}
|
||||||
|
if (!rows.isEmpty() && state != null) {
|
||||||
|
// nuke the cached data so we don't bring back deleted rows
|
||||||
|
state.previousData = null;
|
||||||
|
}
|
||||||
|
filteredAddresses = null; // force refiltering selectedAddresses for updated undefined addrs
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptions(EncodedStringsOptions options) {
|
public void setOptions(EncodedStringsOptions options) {
|
||||||
boolean canReusePrevData = options.equivalentStringCreationOptions(state.options);
|
boolean canReusePrevData = options.equivalentStringCreationOptions(state.options);
|
||||||
ModelState newState = new ModelState(options, canReusePrevData ? state.previousData : null);
|
ModelState newState = new ModelState(options, canReusePrevData ? state.previousData : null);
|
||||||
this.state = newState;
|
this.state = newState;
|
||||||
|
if (!canReusePrevData) {
|
||||||
|
filteredAddresses = null;
|
||||||
|
}
|
||||||
clearData();
|
clearData();
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user