Skip to content

Dynamically assign pathGrob in .onLoad() #3331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions R/zzz.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@
})
}

# Assigning pathGrob in .onLoad ensures that packages that subclass GeomPolygon
# do not install with error `possible error in 'pathGrob(munched$x, munched$y, ':
# unused argument (pathId = munched$group)` despite the fact that this is correct
# usage
pathGrob <- NULL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my own understanding: Why do we need this assignment outside of .onLoad()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied what was in sf:::.onLoad() that @thomasp85 suggested we use as a reference. My guess is that it prevents the superassign from accidentally assigning in the global environment (or prevents a warning to that effect)


.onLoad <- function(...) {
backport_unit_methods()

if (getRversion() < as.numeric_version("3.6")) {
pathGrob <<- function(..., pathId.lengths) {
grid::pathGrob(...)
}
}

.zeroGrob <<- grob(cl = "zeroGrob", name = "NULL")

ggplot_global$theme_current <- theme_gray()
Expand Down