Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343816

Summary: NPE when item from the List is dragged
Product: [Eclipse Project] Platform Reporter: Lakshmi P Shanmugam <lshanmug>
Component: SWTAssignee: Lakshmi P Shanmugam <lshanmug>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 Flags: Silenio_Quarti: review+
Version: 3.7   
Target Milestone: 3.7 RC1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
patch none

Description Lakshmi P Shanmugam CLA 2011-04-26 06:29:09 EDT
Cocoa x86_64 : I20110425-1800

1) Run the DNDExample.
2) Select List as the DragSource.
3) Drag any item from the List.
NPE occurs.

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.swt.widgets.Control.createString(Control.java:965)
	at org.eclipse.swt.widgets.List.tableView_objectValueForTableColumn_row(List.java:1448)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5752)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.drawRect(Widget.java:722)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5434)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.java:4864)
	at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5211)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.NSApplication.nextEventMatchingMask(NSApplication.java:94)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3596)
	at org.eclipse.swt.examples.dnd.DNDExample.open(DNDExample.java:1352)
	at org.eclipse.swt.examples.dnd.DNDExample.main(DNDExample.java:71)
Comment 1 Lakshmi P Shanmugam CLA 2011-04-28 10:47:47 EDT
Created attachment 194276 [details]
patch

In the DNDExample, list.remove() is called in DragFinished. But, the number of items doesn't get updated in the NSTableView. Hence, tableView_objectValueForTableColumn_row() is called for the removed item causing NPE. 
The patch updates the number of items using noteNumberOfRowsChanged(), when required.

Silenio, can you please review?
Comment 2 Lakshmi P Shanmugam CLA 2011-05-02 05:43:37 EDT
Fixed in HEAD > 20110502.
Thanks Silenio.