Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
code style
  • Loading branch information
native-api committed May 18, 2018
commit 6323978b0a0989ec0398ac54429b15d6f5bc4542
37 changes: 19 additions & 18 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,25 @@ static PyThreadState *tcl_tstate = NULL;


#define ACQUIRE_TCL_LOCK \
if (tcl_lock) {\
if (tcl_lock) { \
if (tcl_lock_thread_ident == PyThread_get_thread_ident()) { \
tcl_lock_reentry_count++; \
if(!tcl_lock_reentry_count) \
Py_FatalError("Tcl lock reentry count overflow"); \
} else { \
PyThread_acquire_lock(tcl_lock, 1); \
tcl_lock_thread_ident = PyThread_get_thread_ident(); \
}\
} \
}

#define RELEASE_TCL_LOCK \
if (tcl_lock){\
if (tcl_lock) { \
if (tcl_lock_reentry_count) { \
tcl_lock_reentry_count--; \
} else { \
tcl_lock_thread_ident = 0; \
PyThread_release_lock(tcl_lock); \
}\
} \
}


Expand All @@ -242,18 +242,19 @@ if (tcl_lock){\
ENTER_TCL_CUSTOM_TSTATE(tstate)

#define ENTER_TCL_CUSTOM_TSTATE(tstate) \
Py_BEGIN_ALLOW_THREADS \
ACQUIRE_TCL_LOCK; tcl_tstate = tstate;
Py_BEGIN_ALLOW_THREADS \
ACQUIRE_TCL_LOCK \
tcl_tstate = tstate;

#define LEAVE_TCL \
tcl_tstate = NULL; \
RELEASE_TCL_LOCK; Py_END_ALLOW_THREADS}

#define LEAVE_TCL_WITH_BUSYWAIT(result) \
tcl_tstate = NULL; \
RELEASE_TCL_LOCK;\
if (result == 0)\
Sleep(Tkinter_busywaitinterval);\
RELEASE_TCL_LOCK \
if (result == 0) \
Sleep(Tkinter_busywaitinterval); \
Py_END_ALLOW_THREADS


Expand All @@ -264,7 +265,7 @@ if (tcl_lock){\
Py_BEGIN_ALLOW_THREADS

#define LEAVE_OVERLAP_TCL \
tcl_tstate = NULL; RELEASE_TCL_LOCK; }
tcl_tstate = NULL; RELEASE_TCL_LOCK }

#define ENTER_PYTHON \
{ PyThreadState *tstate = tcl_tstate; tcl_tstate = NULL; PyEval_RestoreThread((tstate)); }
Expand Down Expand Up @@ -2015,7 +2016,7 @@ SetVar(PyObject *self, PyObject *args, int flags)
if (newval) {
LEAVE_OVERLAP
ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, NULL,
newval, flags);
newval, flags);
ENTER_OVERLAP
if (!ok)
Tkinter_Error(self);
Expand All @@ -2038,7 +2039,7 @@ SetVar(PyObject *self, PyObject *args, int flags)
if (newval) {
LEAVE_OVERLAP
ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, name2,
newval, flags);
newval, flags);
ENTER_OVERLAP
if (!ok)
Tkinter_Error(self);
Expand Down Expand Up @@ -2517,8 +2518,8 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
ENTER_PYTHON

/* TBD: no error checking here since we know, via the
* Tkapp_CreateCommand() that the client data is a two-tuple
*/
* Tkapp_CreateCommand() that the client data is a two-tuple
*/
func = data->func;

/* Create argument list (argv1, ..., argvN) */
Expand All @@ -2539,14 +2540,14 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
return PythonCmd_Error();

obj_res = AsObj(res);
if (obj_res) {
Tcl_SetObjResult(interp, obj_res);
rv = TCL_OK;
}
if (obj_res == NULL) {
Py_DECREF(res);
return PythonCmd_Error();
}
else {
Tcl_SetObjResult(interp, obj_res);
rv = TCL_OK;
}

Py_DECREF(res);

Expand Down