1
0
Fork 0
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:
Pawel Piech 2008-03-01 00:49:46 +00:00
parent 86e9c84f41
commit f4f4a35474

View file

@ -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();
} }
} }
} }