summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorstanton <stanton@noemail.net>1999-05-22 02:05:30 (GMT)
committerstanton <stanton@noemail.net>1999-05-22 02:05:30 (GMT)
commit87fbf03d7e3f41f571f3517d3bcb38372f17c969 (patch)
treed52e19e2cc99c6dabb7105a1011d65d927c690df /win
parent3e9ee24ba2f3e26b2efaaece6c48e0d4f4a71c4e (diff)
downloadtk-87fbf03d7e3f41f571f3517d3bcb38372f17c969.zip
tk-87fbf03d7e3f41f571f3517d3bcb38372f17c969.tar.gz
tk-87fbf03d7e3f41f571f3517d3bcb38372f17c969.tar.bz2
Fixed bug in Windows clipboard code when dealing with selections that don't contain locale information.
FossilOrigin-Name: 94ed7695ed170972c371f21392b3a4ded9015d66
Diffstat (limited to 'win')
-rw-r--r--win/tkWinClipboard.c67
1 files changed, 35 insertions, 32 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index cb7d1a8..18fb1f1 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinClipboard.c,v 1.4 1999/05/22 01:59:22 stanton Exp $
+ * RCS: @(#) $Id: tkWinClipboard.c,v 1.5 1999/05/22 02:05:31 stanton Exp $
*/
#include "tkWinInt.h"
@@ -79,44 +79,43 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
Tcl_UniCharToUtfDString((Tcl_UniChar *)data,
Tcl_UniCharLen((Tcl_UniChar *)data), &ds);
GlobalUnlock(handle);
- } else if (IsClipboardFormatAvailable(CF_TEXT)
- && IsClipboardFormatAvailable(CF_LOCALE)) {
+ } else if (IsClipboardFormatAvailable(CF_TEXT)) {
/*
* Determine the encoding to use to convert this text.
*/
- handle = GetClipboardData(CF_LOCALE);
- if (!handle) {
- CloseClipboard();
- goto error;
- }
+ if (IsClipboardFormatAvailable(CF_LOCALE)) {
+ handle = GetClipboardData(CF_LOCALE);
+ if (!handle) {
+ CloseClipboard();
+ goto error;
+ }
- /*
- * Get the locale identifier, determine the proper code page to use,
- * and find the corresponding encoding.
- */
+ /*
+ * Get the locale identifier, determine the proper code page
+ * to use, and find the corresponding encoding.
+ */
- Tcl_DStringInit(&ds);
- Tcl_DStringAppend(&ds, "cp######", -1);
- data = GlobalLock(handle);
-
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, "cp######", -1);
+ data = GlobalLock(handle);
+
- /*
- * Even though the documentation claims that GetLocaleInfo expects an
- * LCID, on Windows 9x it really seems to expect a LanguageID.
- */
+ /*
+ * Even though the documentation claims that GetLocaleInfo
+ * expects an LCID, on Windows 9x it really seems to expect
+ * a LanguageID.
+ */
- locale = LANGIDFROMLCID(*((int*)data));
- GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE,
- Tcl_DStringValue(&ds)+2, Tcl_DStringLength(&ds)-2);
- GlobalUnlock(handle);
-
- encoding = Tcl_GetEncoding(NULL, Tcl_DStringValue(&ds));
- Tcl_DStringFree(&ds);
+ locale = LANGIDFROMLCID(*((int*)data));
+ GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE,
+ Tcl_DStringValue(&ds)+2, Tcl_DStringLength(&ds)-2);
+ GlobalUnlock(handle);
- if (!encoding) {
- CloseClipboard();
- goto error;
+ encoding = Tcl_GetEncoding(NULL, Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
+ } else {
+ encoding = NULL;
}
/*
@@ -125,14 +124,18 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
handle = GetClipboardData(CF_TEXT);
if (!handle) {
- Tcl_FreeEncoding(encoding);
+ if (encoding) {
+ Tcl_FreeEncoding(encoding);
+ }
CloseClipboard();
goto error;
}
data = GlobalLock(handle);
Tcl_ExternalToUtfDString(encoding, data, -1, &ds);
GlobalUnlock(handle);
- Tcl_FreeEncoding(encoding);
+ if (encoding) {
+ Tcl_FreeEncoding(encoding);
+ }
} else {
CloseClipboard();