Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java69
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java24
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java19
4 files changed, 90 insertions, 30 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java
index 4ef94c13e..04c257763 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java
@@ -14,6 +14,7 @@ package org.eclipse.debug.internal.ui.memory.provisional;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Iterator;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.Command;
@@ -375,6 +376,10 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
private PendingPropertyChanges fPendingSyncProperties;
+ // list of menu listeners for popupMenuMgr.
+ private ArrayList fMenuListeners;
+ private MenuManager fMenuMgr;
+
/**
* Identifier for an empty group preceding all context menu actions
* (value <code>"popUpBegin"</code>).
@@ -624,13 +629,13 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
// create context menu
// create pop up menu for the rendering
createActions();
- IMenuListener listener = new IMenuListener() {
+ IMenuListener menuListener = new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
fillContextMenu(mgr);
- }};
-
- createPopupMenu(fTableViewer.getControl(), listener);
- createPopupMenu(fTableViewer.getCursor(), listener);
+ }
+ };
+ createPopupMenu(fTableViewer.getControl(), menuListener);
+ createPopupMenu(fTableViewer.getCursor(), menuListener);
fTableViewer.addSelectionChangedListener(fViewerSelectionChangedListener);
fTableViewer.getTable().getVerticalBar().addSelectionListener(fScrollBarSelectionListener);
@@ -660,27 +665,38 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
private void createPopupMenu(Control control, IMenuListener menuListener)
{
IMemoryRenderingContainer container = getMemoryRenderingContainer();
- MenuManager popupMenuMgr = getPopupMenuManager();
- if (popupMenuMgr == null)
+ if (fMenuMgr == null)
{
- popupMenuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- popupMenuMgr.setRemoveAllWhenShown(true);
+ fMenuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+ fMenuMgr.setRemoveAllWhenShown(true);
IMemoryRenderingSite site = container.getMemoryRenderingSite();
String menuId = container.getId();
ISelectionProvider selProvider = site.getSite().getSelectionProvider();
- // must add additions separator before registering the menu
- // otherwise, we will get an error
- popupMenuMgr.addMenuListener(menuListener);
-
- site.getSite().registerContextMenu(menuId, popupMenuMgr, selProvider);
+ addMenuListener(menuListener);
+
+ site.getSite().registerContextMenu(menuId, fMenuMgr, selProvider);
}
- Menu popupMenu = popupMenuMgr.createContextMenu(control);
+ addMenuListener(menuListener);
+
+ Menu popupMenu = fMenuMgr.createContextMenu(control);
control.setMenu(popupMenu);
}
+
+ private void addMenuListener(IMenuListener menuListener) {
+ if (fMenuListeners == null)
+ fMenuListeners = new ArrayList();
+
+ if (!fMenuListeners.contains(menuListener))
+ {
+ fMenuMgr.addMenuListener(menuListener);
+ fMenuListeners.add(menuListener);
+ }
+ }
+
private BigInteger getInitialSelectedAddress() {
// figure out selected address
BigInteger selectedAddress = (BigInteger) getSynchronizedProperty(AbstractAsyncTableRendering.PROPERTY_SELECTED_ADDRESS);
@@ -717,6 +733,14 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
removeRenderingFromSyncService();
JFaceResources.getFontRegistry().removeListener(this);
+
+ Iterator iter = fMenuListeners.iterator();
+ while (iter.hasNext())
+ {
+ fMenuMgr.removeMenuListener((IMenuListener)iter.next());
+ }
+
+ fMenuListeners.clear();
}
private void addRenderingToSyncService()
@@ -1643,8 +1667,17 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
if (fIsDisposed)
return;
+ fIsDisposed = true;
+
removeListeners();
+ if (fMenuMgr != null)
+ {
+ fMenuMgr.removeAll();
+ fMenuMgr.dispose();
+ fMenuMgr = null;
+ }
+
if (fTableViewer != null)
{
if (fViewerListener != null)
@@ -1674,8 +1707,9 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
protected void updateRenderingLabel(final boolean showAddress)
{
Job job = new Job("Update Rendering Label"){ //$NON-NLS-1$
-
protected IStatus run(IProgressMonitor monitor) {
+ if (fIsDisposed)
+ return Status.OK_STATUS;
fLabel = buildLabel(showAddress);
firePropertyChangedEvent(new PropertyChangeEvent(AbstractAsyncTableRendering.this, IBasicPropertyConstants.P_TEXT, null, fLabel));
return Status.OK_STATUS;
@@ -2210,6 +2244,7 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
* @see org.eclipse.debug.ui.memory.IMemoryRendering#becomesHidden()
*/
public void becomesHidden() {
+
// creates new object for storing potential changes in sync properties
fPendingSyncProperties = new PendingPropertyChanges();
super.becomesHidden();
@@ -2305,6 +2340,8 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
Job job = new Job("becomesVisible") //$NON-NLS-1$
{
protected IStatus run(IProgressMonitor monitor) {
+ if (fIsDisposed)
+ return Status.OK_STATUS;
try {
fContentDescriptor.updateContentBaseAddress();
} catch (DebugException e) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java
index 50ded8701..3d967904e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java
@@ -485,12 +485,18 @@ public class AsyncTableRenderingViewer extends AsyncVirtualContentTableViewer {
{
super.dispose();
- if (!fTableCursor.isDisposed())
+ if (fTableCursor != null && !fTableCursor.isDisposed())
{
fCursorEditor.dispose();
+ fCursorEditor = null;
+
fTableCursor.removeTraverseListener(fCursorTraverseListener);
fTableCursor.removeKeyListener(fCursorKeyAdapter);
fTableCursor.removeMouseListener(fCursorMouseListener);
+ fTableCursor.removeSelectionListener(fCursorSelectionListener);
+
+ fTableCursor.dispose();
+ fTableCursor = null;
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java
index 9284c9979..c7b503b78 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java
@@ -83,6 +83,7 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements
* @since 3.2
*/
private ILabelDecorator fLabelDecorator;
+ private IMenuListener fMenuListener;
/**
* Constructs a new rendering of the given type.
@@ -114,11 +115,19 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements
{
Runnable runnable = new Runnable(){
public void run() {
- ((IMemoryBlockExtension)fMemoryBlock).disconnect(this);
+ ((IMemoryBlockExtension)fMemoryBlock).disconnect(this);
}};
new ConnectionJob(runnable).schedule();
}
+ if (fPopupMenuMgr != null)
+ {
+ fPopupMenuMgr.removeMenuListener(fMenuListener);
+ fPopupMenuMgr.removeAll();
+ fPopupMenuMgr.dispose();
+ fPopupMenuMgr = null;
+ }
+
if (fPropertyListeners != null)
fPropertyListeners = null;
}
@@ -167,7 +176,7 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements
{
Runnable runnable = new Runnable(){
public void run() {
- ((IMemoryBlockExtension)fMemoryBlock).disconnect(this);
+ ((IMemoryBlockExtension)fMemoryBlock).disconnect(this);
}};
new ConnectionJob(runnable).schedule();
}
@@ -329,12 +338,11 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements
ISelectionProvider selProvider = site.getSite().getSelectionProvider();
- // must add additions separator before registering the menu
- // otherwise, we will get an error
- fPopupMenuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }});
+ fMenuListener = new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }};
+ fPopupMenuMgr.addMenuListener(fMenuListener);
site.getSite().registerContextMenu(menuId, fPopupMenuMgr, selProvider);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java
index cfcef3771..68969375f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java
@@ -214,6 +214,8 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
private Shell fToolTipShell;
private FormatTableRenderingAction fFormatRenderingAction;
+
+ private IMenuListener fMenuListener;
private class EventHandleLock
{
@@ -790,11 +792,13 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
createActions();
createPopupMenu(fTableViewer.getControl());
createPopupMenu(fTableCursor);
- getPopupMenuManager().addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- fillContextMenu(manager);
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }});
+
+ fMenuListener = new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ fillContextMenu(manager);
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }};
+ getPopupMenuManager().addMenuListener(fMenuListener);
// now the rendering is successfully created
fIsCreated = true;
@@ -2260,6 +2264,11 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
fToolTipShell.dispose();
+ if (getPopupMenuManager() != null)
+ {
+ getPopupMenuManager().removeMenuListener(fMenuListener);
+ }
+
super.dispose();
} catch (Exception e) {}

Back to the top