summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--win/makefile.vc9
-rw-r--r--win/winMain.c45
3 files changed, 53 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2405d23..d0d0fb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-14 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * win/makefile.vc: Applied patches from tcl bug #801467 from
+ * win/winMain.c: Joe Mistachkin
+
2003-10-12 Jeff Hobbs <jeffh@ActiveState.com>
* generic/tkInt.h: move TkGetOptionSpec to stubs intDecls
diff --git a/win/makefile.vc b/win/makefile.vc
index 73e52fa..7928fc6 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -12,12 +12,12 @@
# Copyright (c) 2001-2002 David Gravereaux.
#
#------------------------------------------------------------------------------
-# RCS: @(#) $Id: makefile.vc,v 1.73 2003/09/26 23:59:26 patthoyts Exp $
+# RCS: @(#) $Id: makefile.vc,v 1.74 2003/10/14 15:35:52 patthoyts Exp $
#------------------------------------------------------------------------------
!if "$(MSVCDIR)" == ""
MSG = ^
-You'll need to run vcvars32.bat from Developer Studio, first, to setup^
+You will need to run vcvars32.bat from Developer Studio, first, to setup^
the environment. Jump to this line to read the new instructions.
!error $(MSG)
!endif
@@ -391,6 +391,7 @@ BASE_CLFAGS = $(cdebug) $(cflags) $(crt) $(TK_INCLUDES)
TK_CFLAGS = $(BASE_CLFAGS) $(TK_DEFINES) -DUSE_TCL_STUBS
CON_CFLAGS = $(cdebug) $(cflags) $(crt) -DCONSOLE
WISH_CFLAGS = $(BASE_CLFAGS) $(TK_DEFINES)
+STUB_CFLAGS = $(cflags) $(cdebug) $(TK_DEFINES)
#---------------------------------------------------------------------
@@ -700,10 +701,10 @@ $(TMP_DIR)\winMain.obj: $(WINDIR)\winMain.c
# and no reference made to a C runtime.
$(TMP_DIR)\tkStubLib.obj : $(GENERICDIR)\tkStubLib.c
- $(cc32) $(cdebug) $(cflags) $(TK_INCLUDES) -Zl -DSTATIC_BUILD -Fo$@ $?
+ $(cc32) $(STUB_CFLAGS) $(TK_INCLUDES) -Zl -DSTATIC_BUILD -Fo$@ $?
$(TMP_DIR)\tkStubImg.obj : $(GENERICDIR)\tkStubImg.c
- $(cc32) $(cdebug) $(cflags) $(TK_INCLUDES) -Zl -DSTATIC_BUILD -Fo$@ $?
+ $(cc32) $(STUB_CFLAGS) $(TK_INCLUDES) -Zl -DSTATIC_BUILD -Fo$@ $?
#---------------------------------------------------------------------
diff --git a/win/winMain.c b/win/winMain.c
index edfd42f..83fe80e 100644
--- a/win/winMain.c
+++ b/win/winMain.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: winMain.c,v 1.15 2002/11/04 07:49:43 davygrvy Exp $
+ * RCS: @(#) $Id: winMain.c,v 1.16 2003/10/14 15:35:52 patthoyts Exp $
*/
#include <tk.h>
@@ -33,12 +33,14 @@
static void setargv _ANSI_ARGS_((int *argcPtr, char ***argvPtr));
static void WishPanic _ANSI_ARGS_(TCL_VARARGS(CONST char *,format));
+static void AppInitExitHandler(ClientData clientData);
#ifdef TK_TEST
extern int Tktest_Init(Tcl_Interp *interp);
#endif /* TK_TEST */
static BOOL consoleRequired = TRUE;
+static char **argvSave = NULL;
/*
* The following #if block allows you to change the AppInit
@@ -111,6 +113,11 @@ WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
setargv(&argc, &argv);
/*
+ * Save this for later, so we can free it.
+ */
+ argvSave = argv;
+
+ /*
* Replace argv[0] with full pathname of executable, and forward
* slashes substituted for backslashes.
*/
@@ -164,6 +171,12 @@ Tcl_AppInit(interp)
Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
/*
+ * This exit handler will be used to free the
+ * resources allocated in this file.
+ */
+ Tcl_CreateExitHandler(AppInitExitHandler, NULL);
+
+ /*
* Initialize the console only if we are running as an interactive
* application.
*/
@@ -244,6 +257,34 @@ WishPanic TCL_VARARGS_DEF(CONST char *,arg1)
#endif
ExitProcess(1);
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * AppInitExitHandler --
+ *
+ * This function is called to cleanup the app init resources before
+ * Tcl is unloaded.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Frees the saved argv and deletes the async exit handler.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+AppInitExitHandler(
+ ClientData clientData)
+{
+ if (argvSave != NULL) {
+ ckfree((char *)argvSave);
+ argvSave = NULL;
+ }
+}
+
/*
*-------------------------------------------------------------------------
*
@@ -299,7 +340,7 @@ setargv(argcPtr, argvPtr)
}
}
}
- argSpace = (char *) Tcl_Alloc(
+ argSpace = (char *) ckalloc(
(unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
argv = (char **) argSpace;
argSpace += size * sizeof(char *);