You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2019/10/19 21:58:12 UTC
[jmeter] branch master updated: JMeterToolBar: Swing APIs (e.g.
Button.setEnabled) must be called on a Swing dispatch thread
This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push:
new 76579c6 JMeterToolBar: Swing APIs (e.g. Button.setEnabled) must be called on a Swing dispatch thread
76579c6 is described below
commit 76579c6613c8a70bdf9e35b1c68ce7468c1ae391
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Sat Oct 19 00:53:35 2019 +0300
JMeterToolBar: Swing APIs (e.g. Button.setEnabled) must be called on a Swing dispatch thread
---
.../java/org/apache/jmeter/gui/util/JMeterToolBar.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java b/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java
index 58ea735..b4dff75 100644
--- a/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java
+++ b/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java
@@ -293,14 +293,18 @@ public class JMeterToolBar extends JToolBar implements LocaleChangeListener {
* {@link Map} of button names and their states
*/
private void updateButtons(Map<String, Boolean> buttonStates) {
- for (Component component : getComponents()) {
- if (component instanceof JButton) {
- JButton button = (JButton) component;
- Boolean enabled = buttonStates.get(button.getActionCommand());
- if (enabled != null) {
- button.setEnabled(enabled.booleanValue());
+ // Swing APIs (e.g. Button.setEnabled) must be called on a Swing dispatch thread
+ boolean synchronous = false;
+ JMeterUtils.runSafe(synchronous, () -> {
+ for (Component component : getComponents()) {
+ if (component instanceof JButton) {
+ JButton button = (JButton) component;
+ Boolean enabled = buttonStates.get(button.getActionCommand());
+ if (enabled != null) {
+ button.setEnabled(enabled);
+ }
}
}
- }
+ });
}
}