Bug 246329 - NullPointerException in DragEditPartsTrackerEx
Summary: NullPointerException in DragEditPartsTrackerEx
Status: NEW
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows Vista
: P3 minor
Target Milestone: ---   Edit
Assignee: Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-05 03:57 EDT by hanshikun CLA
Modified: 2014-05-09 11:11 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hanshikun CLA 2008-09-05 03:57:36 EDT
In some case when drag a shape with Ctrl key , I get a NullPointerException in DragEditPartsTrackerEx like:
java.lang.NullPointerException
	at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.addSourceCommands(DragEditPartsTrackerEx.java:97)
	at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.getCommand(DragEditPartsTrackerEx.java:62)
	at org.eclipse.gef.tools.DragEditPartsTracker.handleDragInProgress(DragEditPartsTracker.java:351)
	at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleDragInProgress(DragEditPartsTrackerEx.java:178)
	at org.eclipse.gef.tools.AbstractTool.mouseDrag(AbstractTool.java:994)
	at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool.java:511)
	at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:230)
...

I check the source code of DragEditPartsTrackerEx.java and find that it maybe a miss in getCommand().
"if (getTargetEditPart()!=null)" is checked following the "addSourceCommands(false, command); " , but targetEditPart is also used in addSourceCommands() method.
In some case targetEditPart is null, NullPointerException is throwed.


	/**
	 * @see org.eclipse.gef.tools.AbstractTool#getCommand()
	 */
	protected Command getCommand() {
		if (!isMove()) {
			CompoundCommand command = new CompoundCommand();
****			addSourceCommands(false, command); 
****			if (getTargetEditPart()!=null){
				command.add(getTargetEditPart().getCommand(getTargetRequest()));
				if (command.canExecute())
					return command;
			} 
			
			
		}
		CompoundCommand command = new CompoundCommand();
		addSourceCommands(true, command);
		return command;
	}
Comment 1 Eclipse Webmaster CLA 2010-07-19 12:30:27 EDT
[GMF Restructure] Bug 319140 : product GMF and component Runtime Diagram was the original product and component for this bug
Comment 2 Harald Böhme CLA 2014-05-09 11:11:27 EDT
This problem remains until current version.
It would be nice if it get fixed.

If you need help, I will provide a patch.