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

Bug 358135

Summary: [Pin&Clone] Pinned view shows wrong content for multiple selection
Product: [Tools] CDT Reporter: Nobody - feel free to take it <nobody>
Component: cdt-debug-dsf-gdbAssignee: Patrick Chuong <pchuong>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: cdtdoug, pawel.1.piech, pchuong
Version: 8.0Flags: pchuong: iplog-
Target Milestone: 8.1.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
fix pchuong: iplog-

Description Nobody - feel free to take it CLA 2011-09-19 12:28:54 EDT
Steps to reproduce:
1. Start two debug sessions
2. Open two Variables view, pin the first view to a stack frame in the first session and the second view to a stack frame in the second session.
3. Select both stack frames in the Debug view.
The second view shows the content from the first selection.
Comment 1 Marc Khouzam CLA 2011-09-19 12:57:10 EDT
I think we use the first context of a multi-select.  I don't believe we ever considered how to properly handled a multi-selection case.
Comment 2 Nobody - feel free to take it CLA 2011-09-19 13:06:20 EDT
(In reply to comment #1)
> I think we use the first context of a multi-select.  I don't believe we ever
> considered how to properly handled a multi-selection case.

It seems the first element of the selection is passed from the platform. I thought the second view wouldn't react to it because it is pinned to another context.
Comment 3 Patrick Chuong CLA 2011-09-19 14:49:30 EDT
Perhaps we should blank out the view if there is a context that is not pinned to the view instance, or filter the selection before firing the event to the pinned view.
Comment 4 Patrick Chuong CLA 2011-09-19 15:19:34 EDT
I am still behind on git :), need to catch up on git for creating patch and commit it back to head. 

Anyway, if you replace DebugEventFilterService#debugContextChanged with this piece of code, you won't see the second view change.

public void debugContextChanged(DebugContextEvent event) {
  ISelection eventContext = event.getContext();
  if (eventContext instanceof IStructuredSelection) {
    List<Object> filteredContextList = new ArrayList<Object>();
    List<?> eventContextList = ((IStructuredSelection)eventContext).toList();
    for (Object o : eventContextList) {
      if (fProvider.isPinnedTo(o)) {
	if (fProvider != event.getDebugContextProvider()) {
          filteredContextList.add(o);
        }
      }
    }
    if (filteredContextList.size() > 0) {
      fProvider.delegateEvent(new DebugContextEvent(fProvider, new StructuredSelection(filteredContextList), event.getFlags()));
    }
  }
}
Comment 5 Nobody - feel free to take it CLA 2011-09-19 15:27:12 EDT
(In reply to comment #4)
Thanks Patrick, I'll try it.
Comment 6 Patrick Chuong CLA 2011-12-15 10:27:05 EST
Created attachment 208443 [details]
fix

Mikhail, can you try out this patch?
Comment 7 Nobody - feel free to take it CLA 2011-12-15 11:23:08 EST
Works fine. Thanks Patrick.
Comment 8 Patrick Chuong CLA 2011-12-15 15:13:20 EST
Verified by Mikhail. Committed to master.
Comment 9 CDT Genie CLA 2011-12-15 15:23:02 EST
*** cdt git genie on behalf of Patrick Chuong ***

    Bug 358135 - [Pin&Clone] Pinned view shows wrong content for multiple
    selection

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=349cdb089d6d56c6e7a8d8b2b5e86e608885b48c