mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[221027] Added a listener to automatically shut down the executor thread when the display is disposed.
This commit is contained in:
parent
86e9c84f41
commit
f4f4a35474
1 changed files with 10 additions and 2 deletions
|
@ -26,6 +26,8 @@ import org.eclipse.dd.dsf.concurrent.DsfExecutable;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.SWTException;
|
import org.eclipse.swt.SWTException;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DSF executor which uses the display thread to run the submitted runnables
|
* DSF executor which uses the display thread to run the submitted runnables
|
||||||
|
@ -61,10 +63,16 @@ public class DisplayDsfExecutor extends DefaultDsfExecutor
|
||||||
*/
|
*/
|
||||||
private final Display fDisplay;
|
private final Display fDisplay;
|
||||||
|
|
||||||
|
|
||||||
private DisplayDsfExecutor(Display display) {
|
private DisplayDsfExecutor(Display display) {
|
||||||
super("Display DSF Executor"); //$NON-NLS-1$
|
super("Display DSF Executor"); //$NON-NLS-1$
|
||||||
fDisplay = display;
|
fDisplay = display;
|
||||||
|
fDisplay.addListener(SWT.Dispose, new Listener() {
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
if (event.type == SWT.Dispose) {
|
||||||
|
DisplayDsfExecutor.super.shutdownNow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,7 +159,7 @@ public class DisplayDsfExecutor extends DefaultDsfExecutor
|
||||||
});
|
});
|
||||||
} catch (SWTException swtException) {
|
} catch (SWTException swtException) {
|
||||||
if (swtException.code == SWT.ERROR_DEVICE_DISPOSED) {
|
if (swtException.code == SWT.ERROR_DEVICE_DISPOSED) {
|
||||||
DisplayDsfExecutor.super.shutdown();
|
DisplayDsfExecutor.super.shutdownNow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue