summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-11-24 10:34:18 (GMT)
committernijtmans <nijtmans>2010-11-24 10:34:18 (GMT)
commit10af58ae7a581a58b233d3edacbd5c11365684e8 (patch)
tree42683cb8d360ac595906b2b8a4d81e842dc49f8d
parentc1eabb3837b46d3387543b02626d1877233d77cc (diff)
downloadtk-10af58ae7a581a58b233d3edacbd5c11365684e8.zip
tk-10af58ae7a581a58b233d3edacbd5c11365684e8.tar.gz
tk-10af58ae7a581a58b233d3edacbd5c11365684e8.tar.bz2
re-write TkpDisplayWarning not to use any Tcl functions any more. This allows TkpDisplayWarning to be used as panic proc on Windows
-rw-r--r--ChangeLog5
-rw-r--r--win/tkWinInit.c24
-rw-r--r--win/winMain.c10
3 files changed, 16 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index ec0e66b..bc7b388 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
2010-11-24 Jan Nijtmans <nijtmans@users.sf.net>
- * win/tkWinDialog.c [Bug #3071836]: Crash/Tcl_Panic on WinXP saving file to C:\
+ * win/tkWinDialog.c: [Bug #3071836]: Crash/Tcl_Panic on WinXP saving file to C:\
+ * win/tkWinInit.c: re-write TkpDisplayWarning not to use any Tcl functions
+ any more. This allows TkpDisplayWarning to be used as panic proc.
+ * win/winMain.c: use TkpDisplayWarning as panic proc on Windows.
2010-11-19 Jan Nijtmans <nijtmans@users.sf.net>
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index 6b30f17..8742e48 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinInit.c,v 1.16 2010/01/13 23:08:11 nijtmans Exp $
+ * RCS: @(#) $Id: tkWinInit.c,v 1.17 2010/11/24 10:34:18 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -118,27 +118,21 @@ TkpDisplayWarning(
const char *msg, /* Message to be displayed. */
const char *title) /* Title of warning. */
{
- Tcl_DString msgString, titleString;
- Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding();
+#define TK_MAX_WARN_LEN 1024
+ WCHAR msgString[TK_MAX_WARN_LEN + 5];
+ WCHAR titleString[TK_MAX_WARN_LEN + 1];
+ MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, TK_MAX_WARN_LEN);
+ MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN);
/*
* Truncate MessageBox string if it is too long to not overflow the screen
* and cause possible oversized window error.
*/
-
-#define TK_MAX_WARN_LEN (1024 * sizeof(WCHAR))
- Tcl_UtfToExternalDString(unicodeEncoding, msg, -1, &msgString);
- Tcl_UtfToExternalDString(unicodeEncoding, title, -1, &titleString);
- if (Tcl_DStringLength(&msgString) > (int) TK_MAX_WARN_LEN) {
- Tcl_DStringSetLength(&msgString, TK_MAX_WARN_LEN);
- Tcl_DStringAppend(&msgString, (char *) L" ...", 4 * sizeof(WCHAR));
- }
- MessageBoxW(NULL, (WCHAR *) Tcl_DStringValue(&msgString),
- (WCHAR *) Tcl_DStringValue(&titleString),
+ memcpy(msgString + TK_MAX_WARN_LEN, L" ...", 5 * sizeof(WCHAR));
+ titleString[TK_MAX_WARN_LEN] = L'\0';
+ MessageBoxW(NULL, msgString, titleString,
MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
| MB_SETFOREGROUND | MB_TOPMOST);
- Tcl_DStringFree(&msgString);
- Tcl_DStringFree(&titleString);
}
/*
diff --git a/win/winMain.c b/win/winMain.c
index 522d496..c679d81 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: winMain.c,v 1.38 2010/11/18 15:54:20 nijtmans Exp $
+ * RCS: @(#) $Id: winMain.c,v 1.39 2010/11/24 10:34:18 nijtmans Exp $
*/
#include "tk.h"
@@ -35,13 +35,13 @@ extern Tcl_PackageInitProc Dde_SafeInit;
#ifdef TCL_BROKEN_MAINARGS
static void setargv(int *argcPtr, TCHAR ***argvPtr);
#endif
+extern void TkpDisplayWarning(const char *, const char *);
/*
* Forward declarations for procedures defined later in this file:
*/
static void WishPanic(const char *format, ...);
-
static BOOL consoleRequired = TRUE;
/*
@@ -277,15 +277,11 @@ WishPanic(
{
va_list argList;
char buf[1024];
- Tcl_DString ds;
MessageBeep(MB_ICONEXCLAMATION);
va_start(argList, format);
vsprintf(buf, format, argList);
- Tcl_WinUtfToTChar(buf, -1, &ds);
- MessageBox(NULL, (TCHAR *)Tcl_DStringValue(&ds), TEXT("Error in Wish"),
- MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
- Tcl_DStringFree(&ds);
+ TkpDisplayWarning(buf, "Error in Wish");
#ifdef _MSC_VER
DebugBreak();
#endif