1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 00:35:49 +02:00

Bug 525666: Fix NPE when DebuggerConsole closes before async code can run

Fix the async calls that can run after the DebuggerConsole is closed
and removed so that they can't NPE.

Change-Id: I7905ee18a92be0ff5de25a4c8d770a694b06bfe1
This commit is contained in:
Jonah Graham 2017-06-08 11:29:59 +01:00
parent 94b8301bbc
commit cfd6e9867e

View file

@ -128,7 +128,10 @@ public class GdbBasicCliConsole extends IOConsole implements IGDBDebuggerConsole
int bufferLines = store.getInt(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES);
Display.getDefault().asyncExec(() -> {
getInputStream().setColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
IOConsoleInputStream inputStream = getInputStream();
if (inputStream != null) {
inputStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
}
fErrorStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
setInvertedColors(enabled);
@ -235,10 +238,15 @@ public class GdbBasicCliConsole extends IOConsole implements IGDBDebuggerConsole
byte[] b = new byte[1024];
int read = 0;
do {
read = getInputStream().read(b);
IOConsoleInputStream inputStream = getInputStream();
if (inputStream == null) {
break;
}
read = inputStream.read(b);
if (read > 0) {
fProcess.getOutputStream().write(b, 0, read);
}
} while (read >= 0);
} catch (IOException e) {
}