1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fixed NPEs in code that is subject to dealing with a disposed frame.

This commit is contained in:
John Cortell 2008-07-23 20:34:01 +00:00
parent 925a43a9cd
commit 0e2c6945bd
3 changed files with 16 additions and 10 deletions

View file

@ -122,8 +122,8 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
return false; return false;
if ( fStartAddress == null || fEndAddress == null ) if ( fStartAddress == null || fEndAddress == null )
return false; return false;
IAddress address = frame.getAddress(); IAddress address = frame.getAddress(); // will return null if frame was disposed
return (address.compareTo( fStartAddress ) >= 0 && address.compareTo( fEndAddress ) <= 0); return (address != null && address.compareTo( fStartAddress ) >= 0 && address.compareTo( fEndAddress ) <= 0);
} }
/* /*

View file

@ -64,8 +64,10 @@ public class DisassemblyInstructionPointerAnnotation extends Annotation {
IDisassembly disassembly = getDisassembly( frame ); IDisassembly disassembly = getDisassembly( frame );
hashCode = 37*hashCode + (( disassembly != null ) ? disassembly.hashCode() : 0); hashCode = 37*hashCode + (( disassembly != null ) ? disassembly.hashCode() : 0);
if ( frame != null ) { if ( frame != null ) {
IAddress address = frame.getAddress(); IAddress address = frame.getAddress(); // will return null if frame has been disposed
hashCode = 37*hashCode + address.hashCode(); if (address != null) {
hashCode = 37*hashCode + address.hashCode();
}
} }
return hashCode; return hashCode;
} }

View file

@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDebugConstants; import org.eclipse.cdt.debug.core.ICDebugConstants;
import org.eclipse.cdt.debug.core.model.ICStackFrame; import org.eclipse.cdt.debug.core.model.ICStackFrame;
@ -587,12 +588,15 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
*/ */
private IRegion getLineInformation( ICStackFrame frame, IEditorInput input ) { private IRegion getLineInformation( ICStackFrame frame, IEditorInput input ) {
if ( input instanceof DisassemblyEditorInput ) { if ( input instanceof DisassemblyEditorInput ) {
int line = ((DisassemblyEditorInput)input).getInstructionLine( frame.getAddress() ); final IAddress address = frame.getAddress(); // will return null if frame has been disposed
if ( line > 0 ) { if (address != null) {
try { int line = ((DisassemblyEditorInput)input).getInstructionLine( address );
return getSourceViewer().getDocument().getLineInformation( --line ); if ( line > 0 ) {
} try {
catch( BadLocationException e1 ) { return getSourceViewer().getDocument().getLineInformation( --line );
}
catch( BadLocationException e1 ) {
}
} }
} }
} }