Skip to content
This repository has been archived by the owner on Mar 27, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Gerring committed May 27, 2015
1 parent 32c71d3 commit 6d4382c
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,27 @@ public void start(BundleContext bundleContext) throws Exception {
int defaultPort = getPreferenceStore().getInt(PreferenceConstants.PREF_DEFAULT_PORT);
if (defaultPort<1) defaultPort = GatewayServer.DEFAULT_PORT;

// We look for a free port and change the preference if the port is not free.
if (!isPortFree(defaultPort)) {
defaultPort = getFreePort(defaultPort);
getPreferenceStore().setValue(PreferenceConstants.PREF_DEFAULT_PORT, defaultPort);
}


int defaultCallBackPort = getPreferenceStore().getInt(PreferenceConstants.PREF_DEFAULT_CALLBACK_PORT);
if (defaultCallBackPort<1) defaultCallBackPort = GatewayServer.DEFAULT_PYTHON_PORT;

// We look for a free port and change the preference if the port is not free.
if (!isPortFree(defaultCallBackPort)) {
defaultCallBackPort = getFreePort(defaultCallBackPort);
getPreferenceStore().setValue(PreferenceConstants.PREF_DEFAULT_CALLBACK_PORT, defaultCallBackPort);
}


if (getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_SWT_DISPLAY_THREAD)) {

server = new SWTGatewayServer(this, getFreePort(defaultPort),
getFreePort(defaultCallBackPort),
server = new SWTGatewayServer(this, defaultPort,
defaultCallBackPort,
GatewayServer.DEFAULT_CONNECT_TIMEOUT,
GatewayServer.DEFAULT_READ_TIMEOUT, null);

Expand All @@ -72,7 +86,14 @@ public void start(BundleContext bundleContext) throws Exception {
} catch (Exception e) {
}
}
server.start();

// Fix to defect whereby cannot access the preferences
// to change the port when the port is already in use.
try {
server.start();
} catch (Throwable ne) {
ne.printStackTrace();
}
}

/**
Expand Down Expand Up @@ -164,4 +185,5 @@ public void run() {
});
}


}

0 comments on commit 6d4382c

Please sign in to comment.