interrupt prompt by closing correctly
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
dd3072615a
commit
e6b4766d89
@ -117,6 +117,7 @@ public final class SWTConsole extends Composite
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
synchronized (promptLock) {
|
synchronized (promptLock) {
|
||||||
|
prompting = false;
|
||||||
promptLock.notifyAll();
|
promptLock.notifyAll();
|
||||||
}
|
}
|
||||||
if (consoleInput.isDisposed()) {
|
if (consoleInput.isDisposed()) {
|
||||||
@ -159,7 +160,10 @@ public final class SWTConsole extends Composite
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see fr.bigeon.gclc.ConsoleManager#print(java.lang.String) */
|
* @see fr.bigeon.gclc.ConsoleManager#print(java.lang.String) */
|
||||||
@Override
|
@Override
|
||||||
public void print(final String text) {
|
public void print(final String text) throws IOException {
|
||||||
|
if (isDisposed()) {
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(new Runnable() {
|
||||||
@SuppressWarnings("synthetic-access")
|
@SuppressWarnings("synthetic-access")
|
||||||
@Override
|
@Override
|
||||||
@ -174,7 +178,10 @@ public final class SWTConsole extends Composite
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see fr.bigeon.gclc.ConsoleManager#println() */
|
* @see fr.bigeon.gclc.ConsoleManager#println() */
|
||||||
@Override
|
@Override
|
||||||
public void println() {
|
public void println() throws IOException {
|
||||||
|
if (isDisposed()) {
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(new Runnable() {
|
||||||
@SuppressWarnings("synthetic-access")
|
@SuppressWarnings("synthetic-access")
|
||||||
@Override
|
@Override
|
||||||
@ -189,7 +196,10 @@ public final class SWTConsole extends Composite
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see fr.bigeon.gclc.ConsoleManager#println(java.lang.String) */
|
* @see fr.bigeon.gclc.ConsoleManager#println(java.lang.String) */
|
||||||
@Override
|
@Override
|
||||||
public void println(final String message) {
|
public void println(final String message) throws IOException {
|
||||||
|
if (isDisposed()) {
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(new Runnable() {
|
||||||
@SuppressWarnings("synthetic-access")
|
@SuppressWarnings("synthetic-access")
|
||||||
@Override
|
@Override
|
||||||
@ -264,7 +274,7 @@ public final class SWTConsole extends Composite
|
|||||||
prompting = true;
|
prompting = true;
|
||||||
command = null;
|
command = null;
|
||||||
promptLock.notifyAll();
|
promptLock.notifyAll();
|
||||||
long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
long cur = start;
|
long cur = start;
|
||||||
while (prompting && start + timeout>cur) {
|
while (prompting && start + timeout>cur) {
|
||||||
promptLock.wait((cur-start-timeout)/2);
|
promptLock.wait((cur-start-timeout)/2);
|
||||||
|
Loading…
Reference in New Issue
Block a user