diff options
author | Uwe Stieber | 2013-10-19 08:08:40 +0000 |
---|---|---|
committer | Uwe Stieber | 2013-10-19 08:09:20 +0000 |
commit | 6322a18981c38177a19ea842860612ca74f5cb3e (patch) | |
tree | a8c29fef83cdeb205c888adba0b11bd6269067d3 | |
parent | 53b46eaf3710a615a861d550c2eeaaf63967d073 (diff) | |
download | org.eclipse.tcf-6322a18981c38177a19ea842860612ca74f5cb3e.tar.gz org.eclipse.tcf-6322a18981c38177a19ea842860612ca74f5cb3e.tar.xz org.eclipse.tcf-6322a18981c38177a19ea842860612ca74f5cb3e.zip |
TCF Debugger: Fix exceptions in memory map widget
3 files changed, 45 insertions, 25 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapDialog.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapDialog.java index 366ba531d..9a86935ce 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapDialog.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapDialog.java @@ -67,6 +67,7 @@ class MemoryMapDialog extends Dialog { try { ILaunchConfigurationWorkingCopy copy = cfg.getWorkingCopy(); if (widget.saveData(copy)) copy.doSave(); + widget.dispose(); super.okPressed(); } catch (Throwable x) { diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java index b91f8ba64..796321f7e 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java @@ -39,8 +39,6 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; @@ -125,6 +123,7 @@ public class MemoryMapWidget { private final ArrayList<ModifyListener> modify_listeners = new ArrayList<ModifyListener>(); private Color cError = null; + private boolean disposed = false; private final IStructuredContentProvider content_provider = new IStructuredContentProvider() { @@ -213,7 +212,7 @@ public class MemoryMapWidget { // Set or reset the symbol file error tooltip marker TableItem[] items = map_table.getItems(); for (TableItem item : items) { - if (item.getData().equals(r)) { + if (item.getData() != null && item.getData().equals(r)) { item.setData("_TOOLTIP", symbolFileInfo); //$NON-NLS-1$ } } @@ -250,13 +249,23 @@ public class MemoryMapWidget { */ @Override public void changed(String context_id) { + // If the widget is already disposed but the listener is still invoked, + // remove the listener itself from the memory map service. + if (disposed) { + if (channel != null) { + IMemoryMap svc = channel.getRemoteService(IMemoryMap.class); + if (svc != null) svc.removeListener(this); + } + return; + } + if (mem_ctx != null && mem_ctx.getID() != null && mem_ctx.getID().equals(context_id)) { if (cfg != null && PlatformUI.getWorkbench().getDisplay() != null && !PlatformUI.getWorkbench().getDisplay().isDisposed()) { final ILaunchConfiguration lc = cfg; PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { - loadData(lc); + if (!disposed) loadData(lc); } }); } @@ -270,30 +279,34 @@ public class MemoryMapWidget { createMemoryMapTable(composite); cError = new Color(composite.getDisplay(), ColorCache.rgb_error); - composite.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - if (cError != null) { - cError.dispose(); - cError = null; - } + } - // Remove the memory map listener - if (channel != null && channel.getState() == IChannel.STATE_OPEN) { - // Asynchronous execution. Make a copy of the current channel reference. - final IChannel c = channel; - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - IMemoryMap svc = c.getRemoteService(IMemoryMap.class); - if (svc != null) svc.removeListener(listener); - } - }); + /** + * Dispose the widget and cleanup the created resources and listeners. + */ + public void dispose() { + if (disposed) return; + disposed = true; + + if (cError != null) { + cError.dispose(); + cError = null; + } + + // Remove the memory map listener + if (channel != null) { + // Asynchronous execution. Make a copy of the current channel reference. + final IChannel c = channel; + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + IMemoryMap svc = c.getRemoteService(IMemoryMap.class); + if (svc != null) svc.removeListener(listener); } - } - }); + }); + } } - + public boolean setTCFNode(TCFNode node) { if (node == null && selection == null || node != null && node.equals(selection)) { return false; diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFMemoryMapTab.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFMemoryMapTab.java index eb5a75a70..21643fd64 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFMemoryMapTab.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFMemoryMapTab.java @@ -107,6 +107,12 @@ public class TCFMemoryMapTab extends AbstractLaunchConfigurationTab { } } + @Override + public void dispose() { + if (widget != null) widget.dispose(); + super.dispose(); + } + public String getName() { return "Symbol Files"; } |