From 4af3066d40cc0babae56064304fc6392ecbe0ceb Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 13 Feb 2013 10:24:12 -0500 Subject: [PATCH] Bug 394183 - MIBreakpointChangedEvent causing NullPointerException in View Model Change-Id: I33559d798f218d358eb491d426f680cfe85ebe13 Reviewed-on: https://git.eclipse.org/r/10337 Reviewed-by: Mikhail Khodjaiants IP-Clean: Mikhail Khodjaiants Tested-by: Mikhail Khodjaiants Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam --- .../mi/service/command/CLIEventProcessor.java | 25 ++++++++++++------- .../command/CLIEventProcessor_7_0.java | 25 ++++++++++++------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java index 454272a7de8..059b177f822 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java @@ -218,18 +218,25 @@ public class CLIEventProcessor { // We know something change, we just do not know what. // So the easiest way is to let the top layer handle it. - MIEvent event = new MIBreakpointChangedEvent( - DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class), 0); - fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class); + if (bpTargetDmc != null) { + MIEvent event = new MIBreakpointChangedEvent(bpTargetDmc, 0); + fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + } } else if (isSettingSignal(operation)) { - // We do no know which signal let the upper layer find it. - MIEvent event = new MISignalChangedEvent( - DMContexts.getAncestorOfType(dmc, ISignalsDMContext.class), ""); //$NON-NLS-1$ - fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + // We do no know which signal let the upper layer find it. + ISignalsDMContext signalDmc = DMContexts.getAncestorOfType(dmc, ISignalsDMContext.class); + if (signalDmc != null) { + MIEvent event = new MISignalChangedEvent(signalDmc, ""); //$NON-NLS-1$ + fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + } } else if (isDetach(operation)) { // if it was a "detach" command change the state. - MIEvent event = new MIDetachedEvent(DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class), token); - fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); + if (controlDmc != null) { + MIEvent event = new MIDetachedEvent(controlDmc, token); + fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + } } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java index 681d26ba0ee..b91401806dd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java @@ -169,18 +169,25 @@ public class CLIEventProcessor_7_0 { // We know something change, we just do not know what. // So the easiest way is to let the top layer handle it. - MIEvent event = new MIBreakpointChangedEvent( - DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class), 0); - fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class); + if (bpTargetDmc != null) { + MIEvent event = new MIBreakpointChangedEvent(bpTargetDmc, 0); + fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + } } else if (isSettingSignal(operation)) { - // We do no know which signal let the upper layer find it. - MIEvent event = new MISignalChangedEvent( - DMContexts.getAncestorOfType(dmc, ISignalsDMContext.class), ""); //$NON-NLS-1$ - fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + // We do no know which signal let the upper layer find it. + ISignalsDMContext signalDmc = DMContexts.getAncestorOfType(dmc, ISignalsDMContext.class); + if (signalDmc != null) { + MIEvent event = new MISignalChangedEvent(signalDmc, ""); //$NON-NLS-1$ + fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + } } else if (isDetach(operation)) { // if it was a "detach" command change the state. - MIEvent event = new MIDetachedEvent(DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class), token); - fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); + if (controlDmc != null) { + MIEvent event = new MIDetachedEvent(controlDmc, token); + fCommandControl.getSession().dispatchEvent(event, fCommandControl.getProperties()); + } } }