Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7134aa

Browse files
committed
return old value of PyMac_DoYieldEnabled; -1 means do not even check for interrupts
1 parent 83c434b commit e7134aa

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

Mac/Modules/macosmodule.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ MacOS_SetScheduleTimes(PyObject *self, PyObject *args)
197197
static PyObject *
198198
MacOS_EnableAppswitch(PyObject *self, PyObject *args)
199199
{
200-
int enable;
200+
int old, new;
201201

202-
if (!PyArg_ParseTuple(args, "i", &enable))
202+
if (!PyArg_ParseTuple(args, "i", &new))
203203
return NULL;
204-
PyMac_DoYieldEnabled = enable;
205-
Py_INCREF(Py_None);
206-
return Py_None;
204+
old = PyMac_DoYieldEnabled;
205+
PyMac_DoYieldEnabled = new;
206+
return Py_BuildValue("i", old);
207207
}
208208

209209

@@ -246,3 +246,4 @@ MacOS_Init()
246246
if (MacOS_Error == NULL || PyDict_SetItemString(d, "Error", MacOS_Error) != 0)
247247
Py_FatalError("can't define MacOS.Error");
248248
}
249+

Mac/Python/macglue.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ static long yield_bg = 12;
115115
static long lastyield;
116116
static int in_foreground;
117117

118-
int PyMac_DoYieldEnabled = 1; /* Don't do eventloop when false */
118+
/*
119+
** When > 0, do full scanning for events (program is not event aware)
120+
** when == 0, only scan for Command-period
121+
** when < 0, don't do any event scanning
122+
*/
123+
int PyMac_DoYieldEnabled = 1;
119124

120125
/* Convert C to Pascal string. Returns pointer to static buffer. */
121126
unsigned char *
@@ -238,6 +243,8 @@ scan_event_queue(flush)
238243
int
239244
PyOS_InterruptOccurred()
240245
{
246+
if (PyMac_DoYieldEnabled < 0)
247+
return 0;
241248
#ifdef THINK_C
242249
scan_event_queue(1);
243250
#endif
@@ -882,3 +889,4 @@ PyMac_InitApplication()
882889
}
883890
Py_Main(argc, argv);
884891
}
892+

0 commit comments

Comments
 (0)