mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-12-21 14:10:37 -06: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;
|
||||
List<ProgramLocation> newStrings = new ArrayList<>();
|
||||
|
||||
setStatusText("Creating strings...");
|
||||
int txId = program.startTransaction("Create Strings");
|
||||
boolean success = false;
|
||||
@@ -780,7 +782,6 @@ public class EncodedStringsDialog extends DialogComponentProvider {
|
||||
monitor.initialize(stringsToCreate.size());
|
||||
monitor.setMessage("Creating strings...");
|
||||
Settings settings = currentOptions.settings();
|
||||
List<ProgramLocation> newStrings = new ArrayList<>();
|
||||
for (EncodedStringsRow row : stringsToCreate) {
|
||||
if (monitor.isCancelled()) {
|
||||
break;
|
||||
@@ -811,26 +812,28 @@ public class EncodedStringsDialog extends DialogComponentProvider {
|
||||
// See table listener for the other end of this
|
||||
rowToSelect.set(selectedRowNums[0]);
|
||||
}
|
||||
StringTranslationService sts = getSelectedStringTranslationService(true);
|
||||
if (sts != null) {
|
||||
Swing.runLater(
|
||||
() -> sts.translate(program, newStrings, new TranslateOptions(true)));
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
finally {
|
||||
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) {
|
||||
createStringsHelper(monitor);
|
||||
Swing.runLater(() -> setActionItemEnablement(true));
|
||||
createStringsHelper(() -> setActionItemEnablement(true), monitor);
|
||||
}
|
||||
|
||||
private void createStringsAndClose(TaskMonitor monitor) {
|
||||
createStringsHelper(monitor);
|
||||
Swing.runLater(this::close);
|
||||
createStringsHelper(this::close, monitor);
|
||||
}
|
||||
|
||||
private void setCreateButtonInfo(int rowCount, int selectedRowCount) {
|
||||
|
||||
@@ -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.
|
||||
@@ -190,12 +190,20 @@ class EncodedStringsTableModel extends AddressBasedTableModel<EncodedStringsRow>
|
||||
for (EncodedStringsRow row : rows) {
|
||||
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) {
|
||||
boolean canReusePrevData = options.equivalentStringCreationOptions(state.options);
|
||||
ModelState newState = new ModelState(options, canReusePrevData ? state.previousData : null);
|
||||
this.state = newState;
|
||||
if (!canReusePrevData) {
|
||||
filteredAddresses = null;
|
||||
}
|
||||
clearData();
|
||||
reload();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user