mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 12:05:21 +02:00
[207785] NPE when trying to send char while no longer connected
This commit is contained in:
parent
02f20b5086
commit
0334a2e1ed
1 changed files with 24 additions and 19 deletions
|
@ -16,6 +16,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [206892] State handling: Only allow connect when CLOSED
|
* Martin Oberhuber (Wind River) - [206892] State handling: Only allow connect when CLOSED
|
||||||
* Martin Oberhuber (Wind River) - [206883] Serial Terminal leaks Jobs
|
* Martin Oberhuber (Wind River) - [206883] Serial Terminal leaks Jobs
|
||||||
* Martin Oberhuber (Wind River) - [208145] Terminal prints garbage after quick disconnect/reconnect
|
* Martin Oberhuber (Wind River) - [208145] Terminal prints garbage after quick disconnect/reconnect
|
||||||
|
* Martin Oberhuber (Wind River) - [207785] NPE when trying to send char while no longer connected
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.emulator;
|
package org.eclipse.tm.internal.terminal.emulator;
|
||||||
|
|
||||||
|
@ -419,27 +420,31 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
protected void sendChar(char chKey, boolean altKeyPressed) {
|
protected void sendChar(char chKey, boolean altKeyPressed) {
|
||||||
try {
|
try {
|
||||||
int byteToSend = chKey;
|
int byteToSend = chKey;
|
||||||
|
OutputStream os = getOutputStream();
|
||||||
if (altKeyPressed) {
|
if (os==null) {
|
||||||
// When the ALT key is pressed at the same time that a character is
|
// Bug 207785: NPE when trying to send char while no longer connected
|
||||||
// typed, translate it into an ESCAPE followed by the character. The
|
Logger.log("NOT sending '" + byteToSend + "' because no longer connected"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// alternative in this case is to set the high bit of the character
|
|
||||||
// being transmitted, but that will cause input such as ALT-f to be
|
|
||||||
// seen as the ISO Latin-1 character '�', which can be confusing to
|
|
||||||
// European users running Emacs, for whom Alt-f should move forward a
|
|
||||||
// word instead of inserting the '�' character.
|
|
||||||
//
|
|
||||||
// TODO: Make the ESCAPE-vs-highbit behavior user configurable.
|
|
||||||
|
|
||||||
Logger.log("sending ESC + '" + byteToSend + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
getOutputStream().write('\u001b');
|
|
||||||
getOutputStream().write(byteToSend);
|
|
||||||
} else {
|
} else {
|
||||||
Logger.log("sending '" + byteToSend + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
if (altKeyPressed) {
|
||||||
getOutputStream().write(byteToSend);
|
// When the ALT key is pressed at the same time that a character is
|
||||||
}
|
// typed, translate it into an ESCAPE followed by the character. The
|
||||||
|
// alternative in this case is to set the high bit of the character
|
||||||
|
// being transmitted, but that will cause input such as ALT-f to be
|
||||||
|
// seen as the ISO Latin-1 character '�', which can be confusing to
|
||||||
|
// European users running Emacs, for whom Alt-f should move forward a
|
||||||
|
// word instead of inserting the '�' character.
|
||||||
|
//
|
||||||
|
// TODO: Make the ESCAPE-vs-highbit behavior user configurable.
|
||||||
|
|
||||||
getOutputStream().flush();
|
Logger.log("sending ESC + '" + byteToSend + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
getOutputStream().write('\u001b');
|
||||||
|
getOutputStream().write(byteToSend);
|
||||||
|
} else {
|
||||||
|
Logger.log("sending '" + byteToSend + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
getOutputStream().write(byteToSend);
|
||||||
|
}
|
||||||
|
getOutputStream().flush();
|
||||||
|
}
|
||||||
} catch (SocketException socketException) {
|
} catch (SocketException socketException) {
|
||||||
Logger.logException(socketException);
|
Logger.logException(socketException);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue