Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.169 diff -c -r1.169 _tkinter.c *** _tkinter.c 8 Mar 2005 15:03:08 -0000 1.169 --- _tkinter.c 4 Aug 2005 01:29:18 -0000 *************** *** 96,128 **** #define HAVE_CREATEFILEHANDLER #endif - #ifdef HAVE_CREATEFILEHANDLER - - /* Tcl_CreateFileHandler() changed several times; these macros deal with the - messiness. In Tcl 8.0 and later, it is not available on Windows (and on - Unix, only because Jack added it back); when available on Windows, it only - applies to sockets. */ - - #ifdef MS_WINDOWS - #define FHANDLETYPE TCL_WIN_SOCKET - #else - #define FHANDLETYPE TCL_UNIX_FD - #endif - - /* If Tcl can wait for a Unix file descriptor, define the EventHook() routine - which uses this to handle Tcl events while the user is typing commands. */ - - #if FHANDLETYPE == TCL_UNIX_FD - #define WAIT_FOR_STDIN - #endif - - #endif /* HAVE_CREATEFILEHANDLER */ - - #ifdef MS_WINDOWS - #include - #define WAIT_FOR_STDIN - #endif - #ifdef WITH_THREAD /* The threading situation is complicated. Tcl is not thread-safe, except --- 96,101 ---- *************** *** 2945,2962 **** {NULL, NULL} }; - #ifdef WAIT_FOR_STDIN - - static int stdin_ready = 0; - - #ifndef MS_WINDOWS - static void - MyFileProc(void *clientData, int mask) - { - stdin_ready = 1; - } - #endif - #ifdef WITH_THREAD static PyThreadState *event_tstate = NULL; #endif --- 2918,2923 ---- *************** *** 2964,2989 **** static int EventHook(void) { ! #ifndef MS_WINDOWS ! int tfile; ! #endif #ifdef WITH_THREAD PyEval_RestoreThread(event_tstate); #endif - stdin_ready = 0; errorInCmd = 0; ! #ifndef MS_WINDOWS ! tfile = fileno(stdin); ! Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL); ! #endif ! while (!errorInCmd && !stdin_ready) { ! int result; ! #ifdef MS_WINDOWS ! if (_kbhit()) { ! stdin_ready = 1; ! break; ! } ! #endif #if defined(WITH_THREAD) || defined(MS_WINDOWS) Py_BEGIN_ALLOW_THREADS if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); --- 2925,2936 ---- static int EventHook(void) { ! int result = 1; #ifdef WITH_THREAD PyEval_RestoreThread(event_tstate); #endif errorInCmd = 0; ! while (!errorInCmd && result) { #if defined(WITH_THREAD) || defined(MS_WINDOWS) Py_BEGIN_ALLOW_THREADS if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); *************** *** 2993,3011 **** tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); - if (result == 0) - Sleep(Tkinter_busywaitinterval); Py_END_ALLOW_THREADS #else result = Tcl_DoOneEvent(0); #endif - - if (result < 0) - break; } - #ifndef MS_WINDOWS - Tcl_DeleteFileHandler(tfile); - #endif if (errorInCmd) { errorInCmd = 0; PyErr_Restore(excInCmd, valInCmd, trbInCmd); --- 2940,2950 ---- *************** *** 3018,3046 **** return 0; } - #endif - static void EnableEventHook(void) { - #ifdef WAIT_FOR_STDIN if (PyOS_InputHook == NULL) { #ifdef WITH_THREAD event_tstate = PyThreadState_Get(); #endif PyOS_InputHook = EventHook; } - #endif } static void DisableEventHook(void) { - #ifdef WAIT_FOR_STDIN if (Tk_GetNumMainWindows() == 0 && PyOS_InputHook == EventHook) { PyOS_InputHook = NULL; } - #endif } --- 2957,2979 ----