Skip to content

Commit 9c620c3

Browse files
committed
Update Swing LaF in the AWT event dispatcher thread
Updating the LookAndFeel within the SWT UI thread may lead to a deadlock when using e.g. the GTKLookAndFeel. The update should be done asynchronously do avoid both treads blocking one another.
1 parent cb726d9 commit 9c620c3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/laf/LookAndFeelTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2025 Google, Inc. and others.
2+
* Copyright (c) 2011, 2026 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -21,6 +21,7 @@
2121
import org.eclipse.wb.internal.swing.laf.model.SystemLafInfo;
2222
import org.eclipse.wb.internal.swing.laf.model.UndefinedLafInfo;
2323
import org.eclipse.wb.internal.swing.model.component.ContainerInfo;
24+
import org.eclipse.wb.internal.swing.utils.SwingUtils;
2425
import org.eclipse.wb.tests.designer.core.TestBundle;
2526
import org.eclipse.wb.tests.designer.swing.SwingModelTest;
2627

@@ -35,7 +36,6 @@
3536
import java.util.concurrent.atomic.AtomicInteger;
3637

3738
import javax.swing.LookAndFeel;
38-
import javax.swing.SwingUtilities;
3939
import javax.swing.UIManager;
4040
import javax.swing.plaf.metal.MetalLookAndFeel;
4141

@@ -53,7 +53,7 @@ public class LookAndFeelTest extends SwingModelTest {
5353
@Override
5454
@AfterEach
5555
public void tearDown() throws Exception {
56-
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
56+
SwingUtils.runLogLater(() -> UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()));
5757
if (m_lastParseInfo != null) {
5858
LafInfo undefinedLAF = UndefinedLafInfo.INSTANCE;
5959
LafSupport.selectLAF(m_lastParseInfo, undefinedLAF);
@@ -415,7 +415,7 @@ public void test_getLAFList() throws Throwable {
415415
for (LafInfo lafInfo : lafList) {
416416
if (!(lafInfo instanceof SeparatorLafInfo)) {
417417
counter.incrementAndGet();
418-
SwingUtilities.invokeLater(() -> {
418+
SwingUtils.runLogLater(() -> {
419419
try {
420420
assertNotNull(lafInfo.getLookAndFeelInstance());
421421
} catch (Throwable t) {

0 commit comments

Comments
 (0)