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

Bug 326152

Summary: [Memory View] new monitors added while Memory view is hidden or closed are not shown in the tree
Product: [Eclipse Project] Platform Reporter: Sean Kennedy <seanpk>
Component: DebugAssignee: Platform-Debug-Inbox <platform-debug-inbox>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: boxall, chanskw, darin.eclipse, pawel.1.piech
Version: 3.6.1   
Target Milestone: 3.6.2   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 326325    
Attachments:
Description Flags
patch none

Description Sean Kennedy CLA 2010-09-24 10:09:35 EDT
Build Identifier: 3.6 I20100608-0911

This is a regression from 3.4.2 to 3.6.
It persists in 3.6.1.

If the user has hidden the Memory view, or the view is not open, when he "monitors memory" the view does not show the new memory monitor in the tree.

You can select the memory from the "Switch memory monitor" drop-down button.  But even after you do that, it still won't show up in the tree.

If you hid the Memory view, and open it again, the new monitor will be shown in the tree, but not selected.

This behaviour is very confusing to users.

Expected behaviour:
Behaviour of the Memory view when a memory monitor is added, should be the same regardless of whether the view is visible, hidden, or closed.
The behaviour when it is visible, is correct.

Reproducible: Always

Steps to Reproduce:
1. Hide or close the Memory view
2. add a new monitor
Comment 1 Darin Wright CLA 2010-09-24 17:09:22 EDT
I enhanced the PDA example debugger with an action to add a memory block, and it works for me when the view is hidden, closed, or visible. I'm calling org.eclipse.debug.core.IMemoryBlockManager.addMemoryBlocks(IMemoryBlock[]). What API is your action using to register the memory block?
Comment 2 Sean Kennedy CLA 2010-09-25 06:46:52 EDT
we are also calling:
org.eclipse.debug.core.IMemoryBlockManager.addMemoryBlocks(IMemoryBlock[])

then we create a rendering, initialize it and call:
org.eclipse.debug.ui.memory.IMemoryRenderingContainer.addMemoryRendering(IMemoryRendering)
Comment 3 Darin Wright CLA 2010-09-27 10:02:57 EDT
This also works for me. Perhaps Samantha can shed more light on the API used to create/add a rendering. I was able to create and show a rendering using the following code - but I don't recall how one is supposed to obtain a rendering container (and know which one it is). I noticed that the memory monitor tree implements the IMemoryRenderingContainer, but it does nothing with renderings. My sample code does this:

IMemoryBlock block = target.getMemoryBlock(0, 1024);
DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks(new IMemoryBlock[]{block});
IViewPart view = DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IDebugUIConstants.ID_MEMORY_VIEW);
if (view != null) {
	if (view instanceof IMemoryRenderingSite) {
		IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
		IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
		IMemoryRendering rendering;
		try {
			rendering = types[0].createRendering();
			IMemoryRenderingSite site = (IMemoryRenderingSite) view;
			IMemoryRenderingContainer[] containers = site.getMemoryRenderingContainers();
			rendering.init(containers[2], block);
			containers[2].addMemoryRendering(rendering);
		} catch (CoreException e) {
			e.printStackTrace();
		}
	}
}
Comment 4 Sean Kennedy CLA 2010-09-27 11:08:14 EDT
our code works fine too when we do a:
org.eclipse.ui.IWorkbenchPage.findView(String)
to get the Memory view, add the monitor, then do a:
org.eclipse.ui.IWorkbenchPage.showView(String)

with 3.4, it worked fine when we just did the
org.eclipse.ui.IWorkbenchPage.showView(String)
first, then added the monitor and rendering to that

we use showView, because findView returns null when the view is closed and then we have to do showView anyway (which demonstrates the same problem)

though I do notice that you're doing the findView after addMemoryBlocks
we were doing that before then ...

yes - if I add the block before getting the view it works
is that how it should always be done?  were we just getting lucky with 3.4?
Comment 5 Darin Wright CLA 2010-09-27 12:20:46 EDT
The signature of org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider.updateNodes(IModelDelta[], int) changed in 3.6 - the "int" (mask) parameter was added to the method, and the subclass MemoryViewTreeModelContentProvider was not updated. Thus, it's implementation of updateNodes(IModelDelta[] nodes) was not being called.
Comment 6 Darin Wright CLA 2010-09-27 12:21:15 EDT
Created attachment 179663 [details]
patch
Comment 7 Darin Wright CLA 2010-09-28 12:16:54 EDT
Released to 3.6.2. Fixed.
Comment 8 Pawel Piech CLA 2011-01-20 18:38:56 EST
Tested with CDt and it seems kosher now.