mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 01:35:39 +02:00
[283586] Traditional Rendering are not disposed after Memory Browser is closed or Debug Session is terminated. Additional fixes from Teo (slightly adjusted)
This commit is contained in:
parent
f37fd1ca20
commit
8e3a1169fe
2 changed files with 66 additions and 30 deletions
|
@ -35,6 +35,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
@ -392,7 +393,10 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
// Minimize leaks. See bugzilla 255120
|
// Fire a terminate event so our hosts can clean up. See 255120 and 283586
|
||||||
|
DebugPlugin.getDefault().fireDebugEventSet( new DebugEvent[]{new DebugEvent( this, DebugEvent.TERMINATE )});
|
||||||
|
|
||||||
|
// Minimize leaks in case we are ourselves are leaked
|
||||||
fDebugTarget = null;
|
fDebugTarget = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,17 +24,17 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.SafeRunner;
|
import org.eclipse.core.runtime.SafeRunner;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
import org.eclipse.debug.core.ILaunchListener;
|
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
import org.eclipse.debug.core.model.IMemoryBlock;
|
import org.eclipse.debug.core.model.IMemoryBlock;
|
||||||
import org.eclipse.debug.core.model.IMemoryBlockExtension;
|
import org.eclipse.debug.core.model.IMemoryBlockExtension;
|
||||||
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
||||||
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
|
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
|
||||||
import org.eclipse.debug.core.model.MemoryByte;
|
import org.eclipse.debug.core.model.MemoryByte;
|
||||||
import org.eclipse.debug.internal.ui.DebugUIMessages;
|
|
||||||
import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager;
|
import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager;
|
||||||
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
|
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
@ -92,6 +92,7 @@ import org.eclipse.ui.IWorkbenchActionConstants;
|
||||||
import org.eclipse.ui.IWorkbenchPreferenceConstants;
|
import org.eclipse.ui.IWorkbenchPreferenceConstants;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.part.ViewPart;
|
import org.eclipse.ui.part.ViewPart;
|
||||||
|
import org.eclipse.ui.progress.UIJob;
|
||||||
import org.eclipse.ui.progress.WorkbenchJob;
|
import org.eclipse.ui.progress.WorkbenchJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +108,7 @@ import org.eclipse.ui.progress.WorkbenchJob;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class MemoryBrowser extends ViewPart implements IDebugContextListener, ILaunchListener, IMemoryRenderingSite
|
public class MemoryBrowser extends ViewPart implements IDebugContextListener, IMemoryRenderingSite, IDebugEventSetListener
|
||||||
{
|
{
|
||||||
public static final String ID = "org.eclipse.cdt.debug.ui.memory.memorybrowser.MemoryBrowser"; //$NON-NLS-1$
|
public static final String ID = "org.eclipse.cdt.debug.ui.memory.memorybrowser.MemoryBrowser"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -236,7 +237,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
selection = contextService.getActiveContext();
|
selection = contextService.getActiveContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
DebugPlugin.getDefault().addDebugEventListener(this);
|
||||||
|
|
||||||
if(selection instanceof StructuredSelection)
|
if(selection instanceof StructuredSelection)
|
||||||
handleDebugContextChanged(((StructuredSelection) selection).getFirstElement());
|
handleDebugContextChanged(((StructuredSelection) selection).getFirstElement());
|
||||||
|
@ -267,7 +268,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
|
DebugPlugin.getDefault().removeDebugEventListener(this);
|
||||||
IDebugContextService contextService =
|
IDebugContextService contextService =
|
||||||
DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow());
|
DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow());
|
||||||
if (isBug145635Patched()) {
|
if (isBug145635Patched()) {
|
||||||
|
@ -279,15 +280,15 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void launchAdded(ILaunch launch) {}
|
/* (non-Javadoc)
|
||||||
public void launchChanged(ILaunch launch) {}
|
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
|
||||||
|
*/
|
||||||
public void launchRemoved(ILaunch launch) {
|
public void handleDebugEvents(DebugEvent[] events) {
|
||||||
// For CDT launch is not adaptable to memory rendering, but the debug targets do.
|
for (DebugEvent event: events) {
|
||||||
for (IDebugTarget target : launch.getDebugTargets()) {
|
Object source = event.getSource();
|
||||||
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) target.getAdapter(IMemoryBlockRetrieval.class));
|
if (event.getKind() == DebugEvent.TERMINATE && source instanceof IMemoryBlockRetrieval) {
|
||||||
if(retrieval != null)
|
releaseTabFolder(source);
|
||||||
releaseTabFolder(retrieval);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +345,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
if(((IMemoryBlockExtension) rendering.getMemoryBlock()).supportBaseAddressModification())
|
if(((IMemoryBlockExtension) rendering.getMemoryBlock()).supportBaseAddressModification())
|
||||||
((IMemoryBlockExtension) rendering.getMemoryBlock()).setBaseAddress(newBase);
|
((IMemoryBlockExtension) rendering.getMemoryBlock()).setBaseAddress(newBase);
|
||||||
rendering.goToAddress(newBase);
|
rendering.goToAddress(newBase);
|
||||||
Display.getDefault().asyncExec(new Runnable(){
|
runOnUIThread(new Runnable(){
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
updateLabel(activeFolder.getSelection(), rendering);
|
updateLabel(activeFolder.getSelection(), rendering);
|
||||||
|
@ -432,6 +433,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
}
|
}
|
||||||
IMemoryBlockExtension block = (IMemoryBlockExtension) item.getData(KEY_MEMORY_BLOCK);
|
IMemoryBlockExtension block = (IMemoryBlockExtension) item.getData(KEY_MEMORY_BLOCK);
|
||||||
try {
|
try {
|
||||||
|
if (block != null)
|
||||||
block.dispose();
|
block.dispose();
|
||||||
} catch (DebugException e) {
|
} catch (DebugException e) {
|
||||||
MemoryBrowserPlugin.getDefault().getLog().log(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, "Could not dispose memory block", e)); //$NON-NLS-1$
|
MemoryBrowserPlugin.getDefault().getLog().log(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, "Could not dispose memory block", e)); //$NON-NLS-1$
|
||||||
|
@ -546,9 +548,11 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
|
|
||||||
if(context instanceof IAdaptable)
|
if(context instanceof IAdaptable)
|
||||||
{
|
{
|
||||||
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) ((IAdaptable) context).getAdapter(IMemoryBlockRetrieval.class));
|
IAdaptable adaptable = (IAdaptable) context;
|
||||||
|
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) adaptable.getAdapter(IMemoryBlockRetrieval.class));
|
||||||
|
ILaunch launch = ((ILaunch) adaptable.getAdapter(ILaunch.class));
|
||||||
|
|
||||||
if(retrieval != null)
|
if(retrieval != null && launch != null && !launch.isTerminated())
|
||||||
{
|
{
|
||||||
fGotoAddressBarControl.setVisible(true);
|
fGotoAddressBarControl.setVisible(true);
|
||||||
CTabFolder tabFolder = getTabFolder(retrieval);
|
CTabFolder tabFolder = getTabFolder(retrieval);
|
||||||
|
@ -678,15 +682,16 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
return fContextFolders.put(context, folder);
|
return fContextFolders.put(context, folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseTabFolder(Object context)
|
private void releaseTabFolder(final Object context)
|
||||||
{
|
{
|
||||||
final CTabFolder folder = getTabFolder(context);
|
final CTabFolder folder = getTabFolder(context);
|
||||||
if(folder != null)
|
if(folder != null)
|
||||||
{
|
{
|
||||||
|
Runnable run = new Runnable() {
|
||||||
|
public void run() {
|
||||||
for(CTabItem tab : folder.getItems()) {
|
for(CTabItem tab : folder.getItems()) {
|
||||||
disposeTab(tab);
|
disposeTab(tab);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fContextFolders.remove(context);
|
fContextFolders.remove(context);
|
||||||
folder.dispose();
|
folder.dispose();
|
||||||
|
|
||||||
|
@ -694,6 +699,10 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
handleUnsupportedSelection();
|
handleUnsupportedSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
runOnUIThread(run);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class SelectionProviderAdapter implements ISelectionProvider {
|
class SelectionProviderAdapter implements ISelectionProvider {
|
||||||
|
|
||||||
|
@ -769,6 +778,29 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
|
||||||
newBlock.dispose();
|
newBlock.dispose();
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute runnable on UI thread if the current thread is not an UI thread.
|
||||||
|
* Otherwise execute it directly.
|
||||||
|
*
|
||||||
|
* @param runnable
|
||||||
|
* the runnable to execute
|
||||||
|
*/
|
||||||
|
private void runOnUIThread(final Runnable runnable)
|
||||||
|
{
|
||||||
|
if (Display.getCurrent() != null) {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UIJob job = new UIJob("Memory Browser UI Job"){ //$NON-NLS-1$
|
||||||
|
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||||
|
runnable.run();
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}};
|
||||||
|
job.setSystem(true);
|
||||||
|
job.schedule();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue