Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2017-06-08 10:29:59 +0000
committerJonah Graham2017-10-06 14:59:19 +0000
commitcfd6e9867ede236878072ed630478685fd43cba0 (patch)
treec1e713965a781f6789e46fbb81a9659dc7ae7bb8
parent94b8301bbc4542cea5fe058f003f99118a0bb1bc (diff)
downloadorg.eclipse.cdt-cfd6e9867ede236878072ed630478685fd43cba0.tar.gz
org.eclipse.cdt-cfd6e9867ede236878072ed630478685fd43cba0.tar.xz
org.eclipse.cdt-cfd6e9867ede236878072ed630478685fd43cba0.zip
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
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java
index 1b4684a0896..4cb3ab321bf 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java
@@ -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) {
}

Back to the top