| Description: |
OriginalBugID: 3647 RFE
Version: 8.3b1
SubmitDate: '1999-11-23'
LastModified: '2000-03-31'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: All Windows
FixedDate: '2000-03-31'
FixedInVersion: 8.3.1
Name:
Jan Nijtmans
CVS:
6 nov 1999
Comments:
This patch is supplied with Wrap 0.3, which requires those modifications.
DesiredBehavior:
- The function TkWinXInit() should be called when Tk is
compiled as a static library.
- The function TkWinGetPlatformId should be moved from
TkWin32Dll.c to TkWinX.c. Otherwise when creating a
static library we don't have the possibility to leave
out DllMain, because TkWinGetPlatformId will be left
out together with it.
- It is not necessary to have both a DllMain and a
DllEntryPoint function. With a proper macro both
functions can be merged in a single one which works
on VC++, Borland and (as extra bonus) with gcc as well.
Patch:
*** generic/tkWindow.c.origWed Apr 21 23:53:28 1999
--- generic/tkWindow.cSat Sep 25 19:39:12 1999
***************
*** 21,26 ****
--- 21,29 ----
#if !defined(__WIN32__) && !defined(MAC_TCL)
#include "tkUnixInt.h"
#endif
+ #if defined(__WIN32__)
+ #include "tkWinInt.h"
+ #endif
typedef struct ThreadSpecificData {
***************
*** 2709,2714 ****
--- 2712,2727 ----
Tcl_DString class;
ThreadSpecificData *tsdPtr;
+ #if defined(__WIN32__) && defined(STATIC_BUILD) && !defined(NO_STATIC_INIT)
+ /*
+ * If we are in a statically linked executable, then we need to
+ * explicitly initialize the Windows function tables here since
+ * DllMain() will not be invoked.
+ */
+
+ TkWinXInit(GetModuleHandle(NULL));
+ #endif
+
/*
* Ensure that we are getting the matching version of Tcl. This is
* really only an issue when Tk is loaded dynamically.
*** win/tkWin32Dll.c.origFri Apr 16 03:51:48 1999
--- win/tkWin32Dll.cSat Sep 25 19:33:35 1999
***************
*** 13,26 ****
#include "tkWinInt.h"
! static int tkPlatformId;
- /*
- * The following declaration is for the VC++ DLL entry point.
- */
-
- BOOL APIENTRYDllMain _ANSI_ARGS_((HINSTANCE hInst,
- DWORD reason, LPVOID reserved));
/*
*----------------------------------------------------------------------
--- 13,22 ----
#include "tkWinInt.h"
! #if defined(_MSC_VER) || defined(__GNUC__)
! #define DllEntryPoint DllMain
! #endif
/*
*----------------------------------------------------------------------
***************
*** 32,63 ****
*routine.
*
* Results:
! *See DllMain.
! *
! * Side effects:
! *See DllMain.
! *
! *----------------------------------------------------------------------
! */
!
! BOOL APIENTRY
! DllEntryPoint(hInst, reason, reserved)
! HINSTANCE hInst;/* Library instance handle. */
! DWORD reason;/* Reason this function is being called. */
! LPVOID reserved;/* Not used. */
! {
! return DllMain(hInst, reason, reserved);
! }
!
! /*
! *----------------------------------------------------------------------
! *
! * DllMain --
! *
! *DLL entry point.
! *
! * Results:
! *TRUE on sucess, FALSE on failure.
*
* Side effects:
*None.
--- 28,34 ----
*routine.
*
* Results:
! *TRUE on success, FALSE otherwise.
*
* Side effects:
*None.
***************
*** 66,77 ****
*/
BOOL APIENTRY
! DllMain(hInstance, reason, reserved)
! HINSTANCE hInstance;
! DWORD reason;
! LPVOID reserved;
{
- OSVERSIONINFO os;
/*
* If we are attaching to the DLL from a new process, tell Tk about
--- 37,47 ----
*/
BOOL APIENTRY
! DllEntryPoint (
! HINSTANCE hInstance,/* Library instance handle. */
! DWORD reason,/* Reason this function is being called. */
! LPVOID reserved)/* Not used. */
{
/*
* If we are attaching to the DLL from a new process, tell Tk about
***************
*** 80,119 ****
*/
if (reason == DLL_PROCESS_ATTACH) {
- os.dwOSVersionInfoSize = sizeof(os);
- GetVersionEx(&os);
- tkPlatformId = os.dwPlatformId;
-
TkWinXInit(hInstance);
} else if (reason == DLL_PROCESS_DETACH) {
TkWinXCleanup(hInstance);
}
return(TRUE);
}
-
- /*
- *----------------------------------------------------------------------
- *
- * TkWinGetPlatformId --
- *
- *Determines whether running under NT, 95, or Win32s, to allow
- *runtime conditional code.
- *
- * Results:
- *The return value is one of:
- * VER_PLATFORM_WIN32sWin32s on Windows 3.1.
- * VER_PLATFORM_WIN32_WINDOWSWin32 on Windows 95.
- * VER_PLATFORM_WIN32_NTWin32 on Windows NT
- *
- * Side effects:
- *None.
- *
- *----------------------------------------------------------------------
- */
-
- int
- TkWinGetPlatformId()
- {
- return tkPlatformId;
- }
-
--- 50,58 ----
*** win/tkWinX.c.origFri Jul 9 04:10:07 1999
--- win/tkWinX.cSat Sep 25 19:33:35 1999
***************
*** 26,31 ****
--- 26,32 ----
*/
int tkpIsWin32s = -1;
+ static int tkPlatformId;
/*
* Declarations of static variables used in this file.
***************
*** 142,148 ****
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&info);
! tkpIsWin32s = (info.dwPlatformId == VER_PLATFORM_WIN32s);
if (childClassInitialized != 0) {
return;
--- 143,150 ----
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&info);
! tkPlatformId = info.dwPlatformId;
! tkpIsWin32s = (tkPlatformId == VER_PLATFORM_WIN32s);
if (childClassInitialized != 0) {
return;
***************
*** 1132,1132 ****
--- 1134,1161 ----
}
+
+ /*
+ *----------------------------------------------------------------------
+ *
+ * TkWinGetPlatformId --
+ *
+ *Determines whether running under NT, 95, or Win32s, to allow
+ *runtime conditional code.
+ *
+ * Results:
+ *The return value is one of:
+ * VER_PLATFORM_WIN32sWin32s on Windows 3.1.
+ * VER_PLATFORM_WIN32_WINDOWSWin32 on Windows 95.
+ * VER_PLATFORM_WIN32_NTWin32 on Windows NT
+ *
+ * Side effects:
+ *None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ int
+ TkWinGetPlatformId()
+ {
+ return tkPlatformId;
+ }
+
PatchFiles:
tkWindow.c tkWin32Dll.c tkWinX.c
The TkWinXInit was added to tkWinInit.c:TkpInit where is can be
safely called without the #def's. The tkPlatformId was moved
to tkWin32Dll.c, but I didn't change the DllEntryPoint (Tcl
uses the same thing, and it works just fine).
-- 03/31/2000 hobbs
|