Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358831 - [Shell] Shell.open throws NullPointerException
Summary: [Shell] Shell.open throws NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5 M2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-25 21:18 EDT by Chris Fairhall CLA
Modified: 2011-09-26 22:14 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Fairhall CLA 2011-09-25 21:18:55 EDT
I have a TableViewer with editable cells and a IMenuListener

If you click on the cell to activator the editor with the left mouse button and quickly right click to activate the menu before the cell editor is active the menu displays. Clicking on my edit menuitem that opens a Dialog throws a NPE.

I'm using the nightly build 1.5.0.20110920-2112

When the Display.setFocusControl method is entered Display.focusControl is not null.
When event.processEvent() is called on line 283 Display.focusControl is set to null.

Here is the stack when Display.focusControl was set to null

Daemon Thread [UIThread [ocs2pdw7ka0f12tzm5x3a9upr]] (Suspended (entry into method setFocusControl in Display))	
	Display.setFocusControl(Control) line: 280	
	Display.access$3(Display, Control) line: 279	
	Display$DisplayAdapter.setFocusControl(Control) line: 2377	
	Text(Control).fixFocus(Control) line: 2396	
	Text(Control).setVisible(boolean) line: 266	
	NullableTextCellEditor(CellEditor).deactivate() line: 270	
	NullableTextCellEditor(CellEditor).deactivate(ColumnViewerEditorDeactivationEvent) line: 911	
	TableViewerEditor(ColumnViewerEditor).applyEditorValue() line: 332	
	ColumnViewerEditor$2.applyEditorValue() line: 152	
	CellEditor$1.run() line: 329	
	SafeRunner.run(ISafeRunnable) line: 42	
	JFaceUtil$1.run(ISafeRunnable) line: 51	
	SafeRunnable.run(ISafeRunnable) line: 175	
	NullableTextCellEditor(CellEditor).fireApplyEditorValue() line: 327	
	NullableTextCellEditor(CellEditor).focusLost() line: 708	
	NullableTextCellEditor.access$1(NullableTextCellEditor) line: 1	
	NullableTextCellEditor$3.focusLost(FocusEvent) line: 62	
	FocusEvent.dispatchToObserver(Object) line: 71	
	FocusEvent(Event).processEvent() line: 44	
	FocusEvent(TypedEvent).processEvent() line: 161	
	Display.setFocusControl(Control) line: 283	
	Display.access$3(Display, Control) line: 279	
	Display$DisplayAdapter.setFocusControl(Control) line: 2377	
	Shell.bringToTop() line: 1210	
	Shell.open() line: 689	
	SecurityEditDialog2(Window).open() line: 812	
	SecurityTableProvider$1.run() line: 89	
	SecurityTableProvider$1(Action).runWithEvent(Event) line: 493	
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 575	
	ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 492	
	ActionContributionItem$5.handleEvent(Event) line: 403	
	UntypedEventAdapter.dispatchEvent(Event) line: 652	
	UntypedEventAdapter.widgetSelected(SelectionEvent) line: 90	
	SelectionEvent.dispatchToObserver(Object) line: 196	
	SelectionEvent(Event).processEvent() line: 44	
	SelectionEvent(TypedEvent).processEvent() line: 161	
	TypedEvent.executeNext() line: 201	
	Display.runPendingMessages() line: 1141	
	Display.readAndDispatch() line: 1131	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2733	
	Workbench.runUI() line: 2694	
	Workbench.access$5(Workbench) line: 2530	
	Workbench$5.run() line: 702	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 685	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 157	
	EntryPoint.createUI() line: 99	
	EntryPointManager.createUI(String) line: 81	
	RWTLifeCycle.createUI() line: 204	
	RWTLifeCycle$UIThreadController.run() line: 88	
	UIThread(Thread).run() line: 662	
	UIThread.run() line: 101	


Line 284 then throws a NPE




java.lang.NullPointerException
	at org.eclipse.swt.widgets.Display.setFocusControl(Display.java:284)
	at org.eclipse.swt.widgets.Display.access$3(Display.java:279)
	at org.eclipse.swt.widgets.Display$DisplayAdapter.setFocusControl(Display.java:2377)
	at org.eclipse.swt.widgets.Shell.bringToTop(Shell.java:1210)
	at org.eclipse.swt.widgets.Shell.open(Shell.java:689)
	at org.eclipse.jface.window.Window.open(Window.java:812)
	at nz.bnz.sb.rap.editor.providers.table.SecurityTableProvider$1.run(SecurityTableProvider.java:89)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:493)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:575)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:492)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:403)
	at org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatchEvent(UntypedEventAdapter.java:652)
	at org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetSelected(UntypedEventAdapter.java:90)
	at org.eclipse.swt.events.SelectionEvent.dispatchToObserver(SelectionEvent.java:196)
	at org.eclipse.rwt.internal.events.Event.processEvent(Event.java:44)
	at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.java:161)
	at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.java:201)
	at org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1141)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1131)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2733)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
	at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:702)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:685)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
	at nz.bnz.sb.rap.EntryPoint.createUI(EntryPoint.java:99)
	at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:81)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:204)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:88)
	at java.lang.Thread.run(Thread.java:662)
	at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:101)
Comment 1 Ivan Furnadjiev CLA 2011-09-26 03:17:59 EDT
The NPE was introduced with the fix for bug 340736. Working on a fix.
Comment 2 Ivan Furnadjiev CLA 2011-09-26 03:51:55 EDT
Fixed in CVS HEAD by caching the current focus control before processing the focus event. Unfortunately, didn't manage to create a simple JUnt test for it. Chris, could you confirm that the issue is fixed?
Comment 3 Chris Fairhall CLA 2011-09-26 22:14:57 EDT
(In reply to comment #2)
> Chris, could you confirm that the issue is fixed?

Yes, its is fixed in 1.5.0.20110926-2111