hadley / helpr

An alternative html help system for R
31 stars 4 forks source link

too many devices #11

Closed schloerke closed 14 years ago

schloerke commented 14 years ago

Somehow, too many devices (50+) are being created. I don't know where. I "dev.off()" every time I create a png file.

It happens after I refresh /package/stats/demo/nlm a few times.

schloerke commented 14 years ago
> helpr_demo("stats","lm.glm")
Error in function (expr, envir = parent.frame(), enclos = NULL, src = NULL)  : 
  too many open devices
> traceback()
8: .Call("R_GD_nullDevice")
7: function (expr, envir = parent.frame(), enclos = NULL, src = NULL) 
   {
       if (missing(src)) {
           src <- paste(deparse(substitute(expr)), collapse = "")
       }
       .Call("R_GD_nullDevice")
       dev.control("enable")
       on.exit(dev.off())
       if (is.null(expr)) {
           return(list(new_source(src)))
       }
       expr <- as.expression(expr)
       if (is.null(enclos)) {
           enclos <- if (is.list(envir) || is.pairlist(envir)) 
               parent.frame()
           else baseenv()
       }
       w <- watchout()
       on.exit(w$close())
       output <- list()
       wHandler <- function(wn) {
           output <<- c(output, w$get_new(), list(wn))
           invokeRestart("muffleWarning")
       }
       eHandler <- function(e) {
           output <<- c(output, w$get_new(), list(e))
       }
       mHandler <- function(m) {
           output <<- c(output, w$get_new(), list(m))
           invokeRestart("muffleMessage")
       }
       ev <- list(value = NULL, visible = FALSE)
       try(ev <- withCallingHandlers(.Internal(eval.with.vis(expr, 
           envir, enclos)), warning = wHandler, error = eHandler, 
           message = mHandler), silent = TRUE)
       output <- c(output, w$get_new())
       c(list(new_source(src)), output, list(new_value(ev$value, 
           ev$visible)))
   }(dots[[1L]][[100L]], dots[[2L]][[100L]], envir = <environment>, 
       enclos = NULL)
6: .Call("do_mapply", FUN, dots, MoreArgs, environment(), PACKAGE = "base")
5: mapply(eval.with.details, parsed$expr, parsed$src, MoreArgs = list(envir = envir, 
       enclos = enclos), SIMPLIFY = FALSE)
4: unlist(mapply(eval.with.details, parsed$expr, parsed$src, MoreArgs = list(envir = envir, 
       enclos = enclos), SIMPLIFY = FALSE), recursive = FALSE)
3: evaluate:::evaluate(txt) at evaluate.r#67
2: evaluate_text(demo_src_c, pic_base_name = str_join(package, "_", 
       pkg_version(package), "_demo")) at demo.r#34
1: helpr_demo("stats", "lm.glm")
> dev.list()
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 
   2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17 
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 
  18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33 
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 
  34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49 
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 
  50   51   52   53   54   55   56   57   58   59   60   61   62   63 
> 
schloerke commented 14 years ago

fix in: http://github.com/hadley/evaluate/commit/e9723eaa71f5fbe18f7c65ec36a26fcdccbdd92e

There were two "on.exit" calls being made. The second one overwrote the first one, so I combined them.