mattcasters commented on code in PR #8900:
URL: https://github.com/apache/hop/pull/8900#discussion_r4262805015
##########
plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupDialog.java:
##########
@@ -659,8 +659,17 @@ protected void setComboBoxes() {
//
String[] fieldNames = ConstUi.sortFieldNames(inputFields);
ciKey[1].setComboValues(fieldNames);
+ // Called from the background thread that reads the input fields: touch
the widget on the UI
+ // thread only, or SWT throws "Invalid thread access".
if (wHashFieldInStream != null && !wHashFieldInStream.isDisposed()) {
- wHashFieldInStream.setItems(fieldNames);
+ wHashFieldInStream
+ .getDisplay()
+ .asyncExec(
+ () -> {
+ if (!wHashFieldInStream.isDisposed()) {
+ wHashFieldInStream.setItems(fieldNames);
Review Comment:
**[bug]** `setItems` now runs on the UI thread, and only after `getData()`
has already called `wHashFieldInStream.setText(...)`.
`BackgroundThreadFacade.start` returns immediately, `getData()` sets the text
before the UI thread reaches its event loop, and this `asyncExec` runs later.
On SWT, `Combo.setItems` clears the entry (`clearText()` on GTK) and does not
send `SWT.Modify`, so the dialog does not even look dirty. `getInfo()` always
writes `wHashFieldInStream.getText()` back, including when the hash option is
disabled. Opening a Combination Lookup and pressing OK therefore drops
`hashFieldInStream`. RAP's `setItems` does not clear the text, so the Hop Web
sweep will not catch this.
**Suggestion:** Inside the `asyncExec` runnable, keep the current text and
put it back after `setItems`. `Combo.setText` always sends `SWT.Modify`, and
`focusTransformName()` has already set `loading` to false, so detach `lsMod`
around the update or the restore marks the transform changed:
```java
String current = wHashFieldInStream.getText();
wHashFieldInStream.removeModifyListener(lsMod);
try {
wHashFieldInStream.setItems(fieldNames);
wHashFieldInStream.setText(current);
} finally {
wHashFieldInStream.addModifyListener(lsMod);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]