@@ -89,7 +89,8 @@ check_inherits <- function(x,
89
89
# ' either `"blending"` or `"compositing"`. If `NULL` (default), support for
90
90
# ' all known blending or compositing operations is queried.
91
91
# ' @param maybe A logical of length 1 determining what the return value should
92
- # ' be in case the device capabilities cannot be assessed.
92
+ # ' be in case the device capabilities cannot be assessed. When the current
93
+ # ' device is the 'null device', `maybe` is returned.
93
94
# ' @param call The execution environment of a currently running function, e.g.
94
95
# ' [`caller_env()`][rlang::caller_env()]. The function will be mentioned in
95
96
# ' warnings and error messages as the source of the warning or error. See
@@ -186,6 +187,14 @@ check_device = function(feature, action = "warn", op = NULL, maybe = FALSE,
186
187
187
188
check_bool(maybe , allow_na = TRUE )
188
189
190
+ # Grab device for checking
191
+ dev_cur <- grDevices :: dev.cur()
192
+ dev_name <- names(dev_cur )
193
+
194
+ if (dev_name == " null device" ) {
195
+ return (maybe )
196
+ }
197
+
189
198
action <- arg_match0(action , c(" test" , " warn" , " abort" ))
190
199
action_fun <- switch (
191
200
action ,
@@ -233,10 +242,6 @@ check_device = function(feature, action = "warn", op = NULL, maybe = FALSE,
233
242
return (FALSE )
234
243
}
235
244
236
- # Grab device for checking
237
- dev_cur <- grDevices :: dev.cur()
238
- dev_name <- names(dev_cur )
239
-
240
245
if (dev_name == " RStudioGD" ) {
241
246
# RStudio opens RStudioGD as the active graphics device, but the back-end
242
247
# appears to be the *next* device. Temporarily set the next device as the
0 commit comments