From bd06c9ab9b19564a270a47582d71efe74664e4b7 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 13 May 2014 16:25:53 +0200 Subject: [PATCH] Terminal: Bug 434749 UnhandledEventLoopException when copying to clipboard while the selection is empty The text copied to the clipboard must not be empty. Change-Id: I4202b3d95419a4395af608a9d5ad30f957c3eff4 Signed-off-by: Anton Leherbauer --- .../terminal/emulator/VT100TerminalControl.java | 10 +++++++--- .../tm/internal/terminal/textcanvas/TextCanvas.java | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index b00380e79cd..e62326d6fa8 100644 --- a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -35,6 +35,7 @@ * Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode * Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers * Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND + * Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -242,9 +243,12 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC } private void copy(int clipboardType) { - Object[] data = new Object[] { getSelection() }; - Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; - fClipboard.setContents(data, types, clipboardType); + String selection = getSelection(); + if (selection.length() > 0) { + Object[] data = new Object[] { selection }; + Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; + fClipboard.setContents(data, types, clipboardType); + } } /* (non-Javadoc) diff --git a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index fe4ec147f55..27012b85b1f 100644 --- a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 Wind River Systems, Inc. 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 @@ -16,6 +16,7 @@ * Anton Leherbauer (Wind River) - [196465] Resizing Terminal changes Scroller location * Anton Leherbauer (Wind River) - [324608] Terminal has strange scrolling behaviour * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically + * Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; @@ -331,9 +332,12 @@ public class TextCanvas extends GridCanvas { return fCellCanvasModel.getSelectedText(); } public void copy() { - Clipboard clipboard = new Clipboard(getDisplay()); - clipboard.setContents(new Object[] { getSelectionText() }, new Transfer[] { TextTransfer.getInstance() }); - clipboard.dispose(); + String selectionText = getSelectionText(); + if (selectionText != null && selectionText.length() > 0) { + Clipboard clipboard = new Clipboard(getDisplay()); + clipboard.setContents(new Object[] { selectionText }, new Transfer[] { TextTransfer.getInstance() }); + clipboard.dispose(); + } } public void selectAll() { fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, fCellCanvasModel.getTerminalText().getWidth());