diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-05-05 13:55:47 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-05-05 13:55:47 (GMT) |
commit | defed109c22cf0e3570fcc2686645ccef8228dfc (patch) | |
tree | 62352d8b850165c0596647d8c111cbe3a2fbfd32 /win/tkWinTest.c | |
parent | 30e203aa908d2974306755ad15d3e93e95a9aee2 (diff) | |
download | tk-defed109c22cf0e3570fcc2686645ccef8228dfc.zip tk-defed109c22cf0e3570fcc2686645ccef8228dfc.tar.gz tk-defed109c22cf0e3570fcc2686645ccef8228dfc.tar.bz2 |
On Windows, use Tcl_WinTCharToUtf() in stead of Tcl_NewUnicodeObj(), since Tcl_WinTCharToUtf() works correctly when TCL_UTF_MAX==6 while Tcl_NewUnicodeObj() doesn't.
All changes taken over from androwish. Thanks to Christian Werner!
And ... on the go ... fixed a few memory leaks correctly detected by Christian.
Diffstat (limited to 'win/tkWinTest.c')
-rw-r--r-- | win/tkWinTest.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/win/tkWinTest.c b/win/tkWinTest.c index d824ee4..6e79df3 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -515,6 +515,7 @@ TestgetwindowinfoObjCmd( Tcl_Obj *childrenObj = NULL; TCHAR buf[512]; int cch, cchBuf = 256; + Tcl_DString ds; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "hwnd"); @@ -542,7 +543,9 @@ TestgetwindowinfoObjCmd( Tcl_NewLongObj(GetWindowLongA(INT2PTR(hwnd), GWL_ID))); cch = GetWindowText(INT2PTR(hwnd), (LPTSTR)buf, cchBuf); - textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch); + Tcl_WinTCharToUtf(buf, cch * sizeof (WCHAR), &ds); + textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6), |