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

Bug 340750

Summary: [breadcrumb]NPE in LaunchView CopyToClipboard action after activating breadcrumb
Product: [Eclipse Project] Platform Reporter: Teodor Madan <teodor.madan>
Component: DebugAssignee: Pawel Piech <pawel.1.piech>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: Michael_Rennie, pawel.1.piech
Version: 3.6Flags: Michael_Rennie: review+
Target Milestone: 3.7 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix.
none
Original patch. pawel.1.piech: iplog-

Description Teodor Madan CLA 2011-03-23 08:31:35 EDT
After activating breadcrumb view by resizing debug view, the tree selection will be lost. When attempting to copy breadcrumb contents using keyboard short-cut (CTRL-C on windows) will end up with a NPE dialog. 

Note that this is not reproducible by invoking "Copy Stack" action from pop-up menu as this will create a tree selection.

Stack trace:
java.lang.NullPointerException
at org.eclipse.jface.viewers.CustomHashtable.hashCode(CustomHashtable.java:264)
at org.eclipse.jface.viewers.CustomHashtable.get(CustomHashtable.java:236)
at org.eclipse.jface.viewers.TreeSelection$InitializeData.<init>(TreeSelection.java:60)
at org.eclipse.jface.viewers.TreeSelection$InitializeData.<init>(TreeSelection.java:52)
at org.eclipse.jface.viewers.TreeSelection.<init>(TreeSelection.java:97)
at org.eclipse.jface.viewers.TreeSelection.<init>(TreeSelection.java:108)
at org.eclipse.debug.internal.ui.views.launch.LaunchViewCopyToClipboardActionDelegate.getPrunedSelection(LaunchViewCopyToClipboardActionDelegate.java:34)
at org.eclipse.debug.internal.ui.viewers.model.VirtualCopyToClipboardActionDelegate.run(VirtualCopyToClipboardActionDelegate.java:98)
at org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate.runWithEvent(AbstractDebugActionDelegate.java:313)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241)
at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:119)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
.....
Comment 1 Teodor Madan CLA 2011-03-23 08:35:24 EDT
Created attachment 191744 [details]
Proposed fix.

Contract with TreeSelection constructor is to pass null for an empty selection. This is the reason of the jface NPE.

Refactor handling of empty selection to not need to create an empty TreeSelection object
Comment 2 Pawel Piech CLA 2011-05-09 13:09:01 EDT
Hi Mike,
I'd like to commit this for RC1, if it's still open.  The fix is safe in that it only affects the narrow breadcrumb scenario.
Comment 3 Pawel Piech CLA 2011-05-09 13:13:14 EDT
Updated priority to reflect that the bug affects our product.
Comment 4 Pawel Piech CLA 2011-05-09 13:50:46 EDT
Created attachment 195113 [details]
Original patch.

I wrote almost identical solution before I found this bug.
Comment 5 Michael Rennie CLA 2011-05-09 14:02:24 EDT
+1 patch works fine
Comment 6 Pawel Piech CLA 2011-05-09 14:30:26 EDT
Thanks Mike, I committed the change.