Skip to content

Commit ad1792c

Browse files
author
murrell
committed
clearer and even safer version of r87275 PROTECT fix
git-svn-id: https://svn.r-project.org/R/trunk@87278 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent fc86584 commit ad1792c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/library/grid/src/path.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ SEXP L_fill(SEXP path, SEXP rule)
4747
/* Get the current device
4848
*/
4949
pGEDevDesc dd = getDevice();
50-
/* currentgp has to be explicitly protected, because resolveGPar()
51-
may change "dd" so that currentgp is no longer protected implicitly */
52-
PROTECT(currentgp = gridStateElement(dd, GSS_GPAR));
50+
/* currentgp is a snapshot from grid state that we modify when we
51+
resolve any pattern fill, so duplicate and protect */
52+
PROTECT(currentgp = duplicate(gridStateElement(dd, GSS_GPAR)));
5353
PROTECT(resolvedFill = resolveGPar(currentgp, FALSE));
5454
gcontextFromgpar(currentgp, 0, &gc, dd);
5555

@@ -79,9 +79,9 @@ SEXP L_fillStroke(SEXP path, SEXP rule)
7979
/* Get the current device
8080
*/
8181
pGEDevDesc dd = getDevice();
82-
/* currentgp has to be explicitly protected, because resolveGPar()
83-
may change dd so that currentgp is no longer protected implicitly */
84-
PROTECT(currentgp = gridStateElement(dd, GSS_GPAR));
82+
/* currentgp is a snapshot from grid state that we modify when we
83+
resolve any pattern fill, so duplicate and protect */
84+
PROTECT(currentgp = duplicate(gridStateElement(dd, GSS_GPAR)));
8585
PROTECT(resolvedFill = resolveGPar(currentgp, FALSE));
8686
gcontextFromgpar(currentgp, 0, &gc, dd);
8787

0 commit comments

Comments
 (0)