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:
dev747368
2025-12-18 00:32:43 +00:00
parent 2f06823fba
commit ec56a87cf9
2 changed files with 24 additions and 13 deletions

View File

@@ -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) {

View File

@@ -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();
}