Fix SWT initialization : wait for SWT thread

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@207 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2008-12-05 11:53:01 +00:00
parent b39622cfef
commit ba076699f2
2 changed files with 15 additions and 1 deletions

View File

@ -107,7 +107,7 @@ public class DavGateway {
HttpClient httpClient = DavGatewayHttpClientFacade.getInstance();
GetMethod getMethod = new GetMethod("http://davmail.sourceforge.net/version.txt");
try {
httpClient.setConnectionTimeout(250);
httpClient.setConnectionTimeout(5000);
int status = httpClient.executeMethod(getMethod);
if (status == HttpStatus.SC_OK) {
versionReader = new BufferedReader(new InputStreamReader(getMethod.getResponseBodyAsStream()));

View File

@ -128,6 +128,8 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
DavGatewayTray.warn("Unable to set look and feel");
}
final Thread mainThread = Thread.currentThread();
new Thread("SWT") {
public void run() {
display = new Display();
@ -254,6 +256,10 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
if (Settings.isFirstStart()) {
settingsFrame.setVisible(true);
}
// ready
synchronized (mainThread) {
mainThread.notify();
}
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
@ -271,6 +277,14 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
}
}
}.start();
// wait for SWT init
try {
synchronized (mainThread) {
mainThread.wait();
}
} catch (InterruptedException e) {
DavGatewayTray.error("Error waiting for SWT init",e);
}
}
}