Skip to content

Commit 1d9d6bc

Browse files
committed
Do not check the device in Display::getPrimaryMonitor
1 parent cc4c178 commit 1d9d6bc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2302,7 +2302,6 @@ long getMsgProc (long code, long wParam, long lParam) {
23022302
* @since 3.0
23032303
*/
23042304
public Monitor getPrimaryMonitor () {
2305-
checkDevice ();
23062305
long hmonitor = OS.MonitorFromWindow (0, OS.MONITOR_DEFAULTTOPRIMARY);
23072306
return getMonitor (hmonitor);
23082307
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Font.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.Assert.assertFalse;
2020
import static org.junit.Assert.assertNotEquals;
2121
import static org.junit.Assert.assertNotNull;
22+
import static org.junit.Assert.assertNull;
2223
import static org.junit.Assert.assertTrue;
2324
import static org.junit.Assert.fail;
2425

@@ -112,7 +113,7 @@ public void setUp() {
112113
}
113114

114115
@Test
115-
public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_graphics_FontData() {
116+
public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_graphics_FontData() throws InterruptedException {
116117
// Test new Font(Device device, FontData fd)
117118
// IllegalArgumentException if the fd argument is null
118119
// SWTError: ERROR_NO_HANDLES, if a font could not be created from the given font data
@@ -172,6 +173,20 @@ public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_gra
172173
fail("No exception thrown for height < 0");
173174
} catch (IllegalArgumentException e) {
174175
}
176+
177+
// using an invalid display
178+
Exception[] thrown = new Exception[1];
179+
Thread t = new Thread(() -> {
180+
try {
181+
new Font(Display.getCurrent(), new FontData());
182+
} catch (Exception e1) {
183+
thrown[0] = e1;
184+
}
185+
});
186+
t.start();
187+
t.join();
188+
189+
assertNull("Exception thrown", thrown[0]);
175190
}
176191

177192
@Test

0 commit comments

Comments
 (0)