Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantha Chan2010-04-23 15:55:47 +0000
committerSamantha Chan2010-04-23 15:55:47 +0000
commit8f7833e9fcacc3636a7fae01384806517b8898a7 (patch)
tree51f966e34b5dee80a195179b1ff827577fc90f6d
parent11fd3a4ffe4d12b244c99caf48e88ac877f2330d (diff)
downloadeclipse.platform.debug-8f7833e9fcacc3636a7fae01384806517b8898a7.tar.gz
eclipse.platform.debug-8f7833e9fcacc3636a7fae01384806517b8898a7.tar.xz
eclipse.platform.debug-8f7833e9fcacc3636a7fae01384806517b8898a7.zip
Bug 293270 - [Memory View] NPE when terminating the debug session
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java64
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java13
2 files changed, 41 insertions, 36 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java
index 6d2b6d689..6dad2ff78 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -63,6 +63,8 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
private Composite fCanvas;
protected String fLabel;
+ private volatile boolean fIsDisposed = false;
+
public AbstractMemoryViewPane(IViewPart parent)
{
super();
@@ -277,34 +279,43 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
Object source = events[i].getSource();
if (events[i].getKind() == DebugEvent.TERMINATE && source instanceof IMemoryBlockRetrieval)
{
+ if (isDisposed())
+ return;
+
//When a memory block retrieval terminates, it and its
//tab folders should be removed from our map.
- IMemoryBlockRetrieval ret = (IMemoryBlockRetrieval)source;
+ final IMemoryBlockRetrieval ret = (IMemoryBlockRetrieval)source;
if (ret != null)
{
- final Integer key = MemoryViewUtil.getHashCode(ret);
- final Object folder = fTabFolderForDebugView.get(key);
- if (folder != null && folder != fEmptyTabFolder && (!((CTabFolder)folder).isDisposed()))
- {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (isDisposed())
+ return;
+
+ Integer key = MemoryViewUtil.getHashCode(ret);
+ Object folder = fTabFolderForDebugView.get(key);
+
+ if (folder != null && folder != fEmptyTabFolder)
+ {
//remove the tab folder , and all contained tab items
disposeOfFolder((CTabFolder) folder);
- if (fTabFolderForDebugView != null)
- fTabFolderForDebugView.remove(key);
+ fTabFolderForDebugView.remove(key);
}
- });
- }
+ }
+ });
}
}
}
-
}
public void dispose()
{
+ if (isDisposed())
+ return;
+ fIsDisposed = true;
+
removeListeners();
// dispose empty folders
@@ -312,20 +323,16 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
// dispose all other folders
try {
-
- if (fTabFolderForDebugView != null) {
- Enumeration enumeration = fTabFolderForDebugView.elements();
-
- while (enumeration.hasMoreElements())
- {
- CTabFolder tabFolder = (CTabFolder)enumeration.nextElement();
- disposeOfFolder(tabFolder);
- }
-
- // set to null so that clean up is only done once
- fTabFolderForDebugView.clear();
- fTabFolderForDebugView = null;
+ Enumeration enumeration = fTabFolderForDebugView.elements();
+
+ while (enumeration.hasMoreElements())
+ {
+ CTabFolder tabFolder = (CTabFolder)enumeration.nextElement();
+ disposeOfFolder(tabFolder);
}
+
+ // Clear the table as all CTabFolder's have been dipose()d
+ fTabFolderForDebugView.clear();
} catch (Exception e) {
DebugUIPlugin.logErrorMessage("Exception occurred when the Memory View is disposed."); //$NON-NLS-1$
@@ -396,6 +403,11 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
return fLabel;
}
+ protected boolean isDisposed()
+ {
+ return fIsDisposed;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.memory.IMemoryBlockListener#MemoryBlockAdded(org.eclipse.debug.core.model.IMemoryBlock)
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
index a2cf26290..137e5b004 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -85,8 +85,6 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
private boolean fCanAddRendering = true;
private boolean fCanRemoveRendering = true;
-
- private boolean fIsDisposed = false;
/**
* @param parent is the view hosting this view pane
@@ -248,7 +246,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
- if (fIsDisposed)
+ if (isDisposed())
return;
// do not schedule job if any of these conditions are true
@@ -898,8 +896,6 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
}
public void dispose() {
- fIsDisposed = true;
-
super.dispose();
fTabFolderForMemoryBlock.clear();
@@ -1134,10 +1130,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
}
}
- private boolean isDisposed()
- {
- return fIsDisposed;
- }
+
public void showCreateRenderingTab()
{

Back to the top