Skip to content

Commit 44420f1

Browse files
committed
Initialize graphics device on startup
1 parent 9aa0772 commit 44420f1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

crates/ark/src/interface.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,16 @@ impl RMain {
513513
startup::source_user_r_profile();
514514
}
515515

516+
// Initialise graphics device so `grDevices::dev.interactive()` returns `TRUE`.
517+
// See https://github.com/posit-dev/positron/issues/7681.
518+
// Needs to happen _after_ sourcing R profiles so users can override the
519+
// graphics device in Rprofile.
520+
unsafe {
521+
if let Err(err) = graphics_device::ps_graphics_device_impl() {
522+
log::warn!("Can't initialize graphics device: {err:?}");
523+
}
524+
}
525+
516526
// Start the REPL. Does not return!
517527
crate::sys::interface::run_r();
518528
}

crates/ark/src/plots/graphics_device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ unsafe extern "C-unwind" fn callback_new_page(dd: pGEcontext, dev: pDevDesc) {
899899
});
900900
}
901901

902-
unsafe fn ps_graphics_device_impl() -> anyhow::Result<SEXP> {
902+
pub(crate) unsafe fn ps_graphics_device_impl() -> anyhow::Result<SEXP> {
903903
// TODO: Don't allow creation of more than one graphics device.
904904

905905
// Create the graphics device.

0 commit comments

Comments
 (0)