From 422aaa39627e3110026da9df235a0e15457ebea3 Mon Sep 17 00:00:00 2001
From: jdishaw <jim@dishaw.org>
Date: Wed, 11 Mar 2015 23:51:40 -0400
Subject: [PATCH] Disable plbuf_write before executing the fill in plP_fill()

- The plP_fill() function cause both the PLESC_FILL and the line draws
to both be in the buffer.
- This cause a double line hatching bug on pattern fills.
- By disabling plbuf_write, the line draws are not written to the buffer.
- When the buffer is executed, the PLESC_FILL will render the fill pattern.
---
 src/plcore.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/plcore.c b/src/plcore.c
index 6f03420..34e3c7f 100644
--- a/src/plcore.c
+++ b/src/plcore.c
@@ -426,15 +426,24 @@ void
 plP_fill( short *x, short *y, PLINT npts )
 {
     PLINT i, clpxmi, clpxma, clpymi, clpyma;
+    PLINT original_plbuf_write;
 
     plsc->page_status = DRAWING;
 
+    // Preserve the original state so that it can be restored at the end
+    original_plbuf_write = plsc->plbuf_write;
+
     if ( plsc->plbuf_write )
     {
         plsc->dev_npts = npts;
         plsc->dev_x    = x;
         plsc->dev_y    = y;
         plbuf_esc( plsc, PLESC_FILL, NULL );
+
+	// Turn off buffer writing while rendering the fill.  The
+	// PLESC_FILL will cause the buffer to execute the fill and
+	// this avoids the double line hatching bug.
+	plsc->plbuf_write = 0;
     }
 
 // Account for driver ability to do fills
@@ -480,6 +489,9 @@ plP_fill( short *x, short *y, PLINT npts )
             grfill( x, y, npts );
         }
     }
+
+    // Restore the original plbuf_write state
+    plsc->plbuf_write = original_plbuf_write; 
 }
 
 // Render a gradient
-- 
1.7.10.4

