Skip to content

Commit 1efcd85

Browse files
author
kalibera
committed
Do not call the message loop on Windows recursively to avoid crashes.
git-svn-id: https://svn.r-project.org/R/trunk@88372 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 33c7de8 commit 1efcd85

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/gnuwin32/system.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,30 @@ void unset_R_Tcldo(DO_FUNC ptr)
120120
return;
121121
}
122122

123+
static int pedepth = 0;
124+
125+
static void depth_cleanup(void *data)
126+
{
127+
pedepth = *(int *)data;
128+
}
129+
123130
void R_ProcessEvents(void)
124131
{
125-
while (peekevent()) doevent();
132+
int old_depth = pedepth;
133+
RCNTXT cntxt;
134+
135+
/* do not enter the graphapp message loop recursively */
136+
if (!pedepth && peekevent()) {
137+
pedepth++;
138+
cntxt.cend = &depth_cleanup;
139+
cntxt.cenddata = &old_depth;
140+
begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv,
141+
R_NilValue, R_NilValue);
142+
while (peekevent()) doevent();
143+
endcontext(&cntxt);
144+
depth_cleanup(&old_depth);
145+
}
146+
126147
if (cpuLimit > 0.0 || elapsedLimit > 0.0) {
127148
#ifdef HAVE_CHECK_TIME_LIMITS
128149
/* switch to using R_CheckTimeLimits after testing on Windows */

0 commit comments

Comments
 (0)