Dear R developers, I've been experimenting with embedding R X11 windows into another application using KDE's QXEmbed on linux. Attempting to do so will crash R (with R 2.4.0, trunk, and I know the bug has been around in prior versions). I used to think this was related to bug #848, but I'm not sure, if / how the solution suggested there still applies to current versions of R.
After debugging, I came up with the following patch (in src/modules/X11): Index: devX11.c =================================================================== --- devX11.c (revision 39818) +++ devX11.c (working copy) @@ -586,8 +586,8 @@ if (event.xany.type == Expose) { while(XCheckTypedEvent(display, Expose, &event)) ; - XFindContext(display, event.xexpose.window, - devPtrContext, &temp); + if (XFindContext(display, event.xexpose.window, + devPtrContext, &temp)) return; dd = (NewDevDesc *) temp; if (event.xexpose.count == 0) do_update = 1; @@ -595,8 +595,8 @@ else if (event.type == ConfigureNotify) { while(XCheckTypedEvent(display, ConfigureNotify, &event)) ; - XFindContext(display, event.xconfigure.window, - devPtrContext, &temp); + if (XFindContext(display, event.xconfigure.window, + devPtrContext, &temp)) return; dd = (NewDevDesc *) temp; xd = (newX11Desc *) dd->deviceSpecific; if (xd->windowWidth != event.xconfigure.width || @@ -614,8 +614,8 @@ else if ((event.type == ClientMessage) && (event.xclient.message_type == _XA_WM_PROTOCOLS)) if (!inclose && event.xclient.data.l[0] == protocol) { - XFindContext(display, event.xclient.window, - devPtrContext, &temp); + if (XFindContext(display, event.xclient.window, + devPtrContext, &temp)) return; dd = (NewDevDesc *) temp; KillDevice((DevDesc*) GetDevice(devNumber((DevDesc*) dd))); } I'll have to admit, that I'm mostly clueless as far as X11-programming is concerned, so the patch may not be entirely correct. It does fix the crash, however, and should be along the right lines. The rationale is, that apparently calls to XFindContext() may fail in the context of embedding the X11 window. The patch simply checks the return value of XFindContext() for a non-zero (i.e. error) value, and in that case drops out of the function. Does this seem like a valid fix? Should I provide more info? Regards Thomas Friedrichsmeier
pgpKMLM5Olgw9.pgp
Description: PGP signature
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel