Bug 16438 - getGraphicsEvent crashes R on closing other inactive devices
Summary: getGraphicsEvent crashes R on closing other inactive devices
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.2.1
Hardware: x86_64/x64/amd64 (64-bit) All
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-06-22 14:31 UTC by Mark O'Connell
Modified: 2015-07-22 07:30 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark O'Connell 2015-06-22 14:31:31 UTC
It seems that if more than one graphics device are open, and getGraphicsEvent is called to listen for events on the active device, closing an INACTIVE graphics device crashes R. I have observed this on Windows, Mac (with X11) and Linux (with X-lib). The following code assumes X11 or X-lib devices are available on Mac and Linux machines respectively.

Code to reproduce:

## Begin code
## Open two suitable graphics devices
if (identical(version$os, "linux-gnu")) x11(type = "Xlib") else x11()
plot.new()
if (identical(version$os, "linux-gnu")) x11(type = "Xlib") else x11()
plot.new()
## define mouseclick function to plot a point where you click
mouseclick <- function(buttons, x, y){
    points(grconvertX(x, "ndc", "user"), grconvertY(y, "ndc", "user"))
}
## set up event handlers, and environment then call getGraphicsEvent().
setGraphicsEventHandlers(onMouseDown = mouseclick)
eventEnv <- getGraphicsEventEnv()
getGraphicsEvent()
## Click around the active device, points appear. Close the inactive device
## and R seems to crash.
## End code
Comment 1 Duncan Murdoch 2015-06-22 17:08:18 UTC
I can confirm this; will soon commit a fix to R-devel and R-patched.