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;
if ( fStartAddress == null || fEndAddress == null )
return false;
IAddress address = frame.getAddress();
return (address.compareTo( fStartAddress ) >= 0 && address.compareTo( fEndAddress ) <= 0);
IAddress address = frame.getAddress(); // will return null if frame was disposed
return (address != null && address.compareTo( fStartAddress ) >= 0 && address.compareTo( fEndAddress ) <= 0);
}
/*

View file

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

View file

@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDebugConstants;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
@ -587,7 +588,9 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
*/
private IRegion getLineInformation( ICStackFrame frame, IEditorInput input ) {
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 (address != null) {
int line = ((DisassemblyEditorInput)input).getInstructionLine( address );
if ( line > 0 ) {
try {
return getSourceViewer().getDocument().getLineInformation( --line );
@ -596,6 +599,7 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
}
}
}
}
return null;
}