This is with current tip of DWT2 for Windows (119:d00e8db0a568), using DMD 2.052.
When syncExec is run from a different thread than the main one, it tries to run the Runnable argument in that thread. It should use the main thread. I'm guessing the switch to thread-local by default caused this bug, but I haven't debugged it enough to be sure.
Test case below, in case anyone wants to look into this. It prints "secondary", correct output would be "main".
module test;
import std.stdio;
import core.thread;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Event;
import java.lang.all;
void f()
{
Display.getDefault().syncExec(dgRunnable({
writeln("in thread: ", core.thread.Thread.getThis().name);
}));
}
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setSize(200, 200);
shell.setLayout(new FillLayout);
Button button = new Button(shell, SWT.PUSH);
button.setText("Click here");
button.addListener(SWT.Selection, new class Listener {
void handleEvent(Event event)
{
core.thread.Thread.getThis().name = "main";
auto t = new core.thread.Thread(&f);
t.name = "secondary";
t.start();
}});
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}