mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 342840: Clipboard is not disposed.
This commit is contained in:
parent
3ed57b3aa3
commit
579a0fdfa8
3 changed files with 18 additions and 34 deletions
|
@ -17,8 +17,12 @@ import java.io.PrintWriter;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||||
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
import org.eclipse.osgi.util.TextProcessor;
|
import org.eclipse.osgi.util.TextProcessor;
|
||||||
|
|
||||||
import org.eclipse.swt.SWTError;
|
import org.eclipse.swt.SWTError;
|
||||||
import org.eclipse.swt.dnd.Clipboard;
|
import org.eclipse.swt.dnd.Clipboard;
|
||||||
import org.eclipse.swt.dnd.DND;
|
import org.eclipse.swt.dnd.DND;
|
||||||
|
@ -27,14 +31,6 @@ import org.eclipse.swt.dnd.Transfer;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.part.ViewPart;
|
import org.eclipse.ui.part.ViewPart;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.SelectionUtil;
|
import org.eclipse.cdt.internal.ui.util.SelectionUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,13 +41,10 @@ public class CopyTreeAction extends Action {
|
||||||
|
|
||||||
private ViewPart fView;
|
private ViewPart fView;
|
||||||
private TreeViewer fViewer;
|
private TreeViewer fViewer;
|
||||||
private final Clipboard fClipboard;
|
|
||||||
|
|
||||||
public CopyTreeAction(String label, ViewPart view, Clipboard clipboard, TreeViewer viewer) {
|
public CopyTreeAction(String label, ViewPart view, TreeViewer viewer) {
|
||||||
super(label);
|
super(label);
|
||||||
Assert.isNotNull(clipboard);
|
|
||||||
fView= view;
|
fView= view;
|
||||||
fClipboard= clipboard;
|
|
||||||
fViewer= viewer;
|
fViewer= viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +72,9 @@ public class CopyTreeAction extends Action {
|
||||||
addChildren(fViewer.getTree().getSelection()[0], 0, buf);
|
addChildren(fViewer.getTree().getSelection()[0], 0, buf);
|
||||||
|
|
||||||
TextTransfer plainTextTransfer= TextTransfer.getInstance();
|
TextTransfer plainTextTransfer= TextTransfer.getInstance();
|
||||||
|
Clipboard clipboard= new Clipboard(fView.getSite().getShell().getDisplay());
|
||||||
try {
|
try {
|
||||||
fClipboard.setContents(
|
clipboard.setContents(
|
||||||
new String[] { convertLineTerminators(buf.toString()) },
|
new String[] { convertLineTerminators(buf.toString()) },
|
||||||
new Transfer[] { plainTextTransfer });
|
new Transfer[] { plainTextTransfer });
|
||||||
} catch (SWTError e) {
|
} catch (SWTError e) {
|
||||||
|
@ -90,6 +84,8 @@ public class CopyTreeAction extends Action {
|
||||||
ActionMessages.CopyTreeAction_problem, ActionMessages.CopyTreeAction_clipboard_busy)) {
|
ActionMessages.CopyTreeAction_problem, ActionMessages.CopyTreeAction_clipboard_busy)) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
clipboard.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +106,8 @@ public class CopyTreeAction extends Action {
|
||||||
|
|
||||||
if (item.getExpanded()) {
|
if (item.getExpanded()) {
|
||||||
TreeItem[] items= item.getItems();
|
TreeItem[] items= item.getItems();
|
||||||
for (int i= 0; i < items.length; i++) {
|
for (TreeItem item2 : items) {
|
||||||
addChildren(items[i], indent + 1, buf);
|
addChildren(item2, indent + 1, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerComparator;
|
import org.eclipse.jface.viewers.ViewerComparator;
|
||||||
import org.eclipse.jface.viewers.ViewerFilter;
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.dnd.Clipboard;
|
|
||||||
import org.eclipse.swt.dnd.DND;
|
import org.eclipse.swt.dnd.DND;
|
||||||
import org.eclipse.swt.dnd.DropTarget;
|
import org.eclipse.swt.dnd.DropTarget;
|
||||||
import org.eclipse.swt.dnd.Transfer;
|
import org.eclipse.swt.dnd.Transfer;
|
||||||
|
@ -105,8 +104,6 @@ public class CHViewPart extends ViewPart {
|
||||||
|
|
||||||
private ArrayList<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
|
private ArrayList<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
|
||||||
|
|
||||||
private Clipboard fClipboard;
|
|
||||||
|
|
||||||
// widgets
|
// widgets
|
||||||
private PageBook fPagebook;
|
private PageBook fPagebook;
|
||||||
private Composite fViewerPage;
|
private Composite fViewerPage;
|
||||||
|
@ -208,8 +205,6 @@ public class CHViewPart extends ViewPart {
|
||||||
|
|
||||||
getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, fTreeViewer));
|
getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, fTreeViewer));
|
||||||
|
|
||||||
fClipboard = new Clipboard(parent.getDisplay());
|
|
||||||
|
|
||||||
initDragAndDrop();
|
initDragAndDrop();
|
||||||
createActions();
|
createActions();
|
||||||
createContextMenu();
|
createContextMenu();
|
||||||
|
@ -489,7 +484,7 @@ public class CHViewPart extends ViewPart {
|
||||||
|
|
||||||
fHistoryAction = new CHHistoryDropDownAction(this);
|
fHistoryAction = new CHHistoryDropDownAction(this);
|
||||||
|
|
||||||
fCopyAction= new CopyCallHierarchyAction(this, fClipboard, fTreeViewer);
|
fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer);
|
||||||
|
|
||||||
// setup action bar
|
// setup action bar
|
||||||
// global action hooks
|
// global action hooks
|
||||||
|
@ -811,9 +806,8 @@ public class CHViewPart extends ViewPart {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CopyCallHierarchyAction extends CopyTreeAction {
|
private static class CopyCallHierarchyAction extends CopyTreeAction {
|
||||||
public CopyCallHierarchyAction(ViewPart view, Clipboard clipboard, TreeViewer viewer) {
|
public CopyCallHierarchyAction(ViewPart view, TreeViewer viewer) {
|
||||||
super(CHMessages.CHViewPart_CopyCallHierarchy_label, view, clipboard, viewer);
|
super(CHMessages.CHViewPart_CopyCallHierarchy_label, view, viewer);
|
||||||
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.CALL_HIERARCHY_COPY_ACTION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.eclipse.swt.accessibility.AccessibleEvent;
|
||||||
import org.eclipse.swt.custom.CLabel;
|
import org.eclipse.swt.custom.CLabel;
|
||||||
import org.eclipse.swt.custom.SashForm;
|
import org.eclipse.swt.custom.SashForm;
|
||||||
import org.eclipse.swt.custom.ViewForm;
|
import org.eclipse.swt.custom.ViewForm;
|
||||||
import org.eclipse.swt.dnd.Clipboard;
|
|
||||||
import org.eclipse.swt.dnd.DND;
|
import org.eclipse.swt.dnd.DND;
|
||||||
import org.eclipse.swt.dnd.DropTarget;
|
import org.eclipse.swt.dnd.DropTarget;
|
||||||
import org.eclipse.swt.dnd.Transfer;
|
import org.eclipse.swt.dnd.Transfer;
|
||||||
|
@ -142,8 +141,6 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
|
||||||
private ArrayList<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
|
private ArrayList<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
|
||||||
private int fIgnoreSelectionChanges= 0;
|
private int fIgnoreSelectionChanges= 0;
|
||||||
|
|
||||||
private Clipboard fClipboard;
|
|
||||||
|
|
||||||
// widgets
|
// widgets
|
||||||
private PageBook fPagebook;
|
private PageBook fPagebook;
|
||||||
private Label fInfoText;
|
private Label fInfoText;
|
||||||
|
@ -235,8 +232,6 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
|
||||||
|
|
||||||
initSelectionProvider();
|
initSelectionProvider();
|
||||||
|
|
||||||
fClipboard = new Clipboard(parent.getDisplay());
|
|
||||||
|
|
||||||
initDragAndDrop();
|
initDragAndDrop();
|
||||||
createActions();
|
createActions();
|
||||||
createContextMenu();
|
createContextMenu();
|
||||||
|
@ -785,7 +780,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
|
||||||
|
|
||||||
fHistoryAction = new THHistoryDropDownAction(this);
|
fHistoryAction = new THHistoryDropDownAction(this);
|
||||||
|
|
||||||
fCopyAction= new CopyTypeHierarchyAction(this, fClipboard, fHierarchyTreeViewer);
|
fCopyAction= new CopyTypeHierarchyAction(this, fHierarchyTreeViewer);
|
||||||
|
|
||||||
// setup action bar
|
// setup action bar
|
||||||
// global action hooks
|
// global action hooks
|
||||||
|
@ -1132,9 +1127,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CopyTypeHierarchyAction extends CopyTreeAction {
|
private static class CopyTypeHierarchyAction extends CopyTreeAction {
|
||||||
public CopyTypeHierarchyAction(ViewPart view, Clipboard clipboard, TreeViewer viewer) {
|
public CopyTypeHierarchyAction(ViewPart view, TreeViewer viewer) {
|
||||||
super(Messages.THViewPart_CopyTypeHierarchy, view, clipboard, viewer);
|
super(Messages.THViewPart_CopyTypeHierarchy, view, viewer);
|
||||||
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TYPE_HIERARCHY_COPY_ACTION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue