changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/cmd/gs/src/gsdevice.c

revision 7253: 986e26228cfe
parent 0: eaccc3e8d226
     1.1--- a/sys/src/cmd/gs/src/gsdevice.c
     1.2+++ b/sys/src/cmd/gs/src/gsdevice.c
     1.3@@ -480,21 +480,30 @@ gx_device_retain(gx_device *dev, bool re
     1.4 int
     1.5 gs_nulldevice(gs_state * pgs)
     1.6 {
     1.7+    int code = 0;
     1.8+    int saveLockSafety = false;
     1.9+
    1.10     if (pgs->device == 0 || !gx_device_is_null(pgs->device)) {
    1.11-	gx_device *ndev;
    1.12-	int code = gs_copydevice(&ndev, (const gx_device *)&gs_null_device,
    1.13-				 pgs->memory);
    1.14-
    1.15+        gx_device *ndev;
    1.16+        code = gs_copydevice(&ndev, (const gx_device *)&gs_null_device, pgs->memory);
    1.17 	if (code < 0)
    1.18 	    return code;
    1.19+        if (gs_currentdevice_inline(pgs) != NULL)
    1.20+            saveLockSafety = gs_currentdevice_inline(pgs)->LockSafetyParams;
    1.21+
    1.22 	/*
    1.23 	 * Internal devices have a reference count of 0, not 1,
    1.24 	 * aside from references from graphics states.
    1.25 	 */
    1.26 	rc_init(ndev, pgs->memory, 0);
    1.27-	return gs_setdevice_no_erase(pgs, ndev);
    1.28+        code = gs_setdevice_no_erase(pgs, ndev);
    1.29+        if (code < 0) {
    1.30+            gs_free_object(pgs->memory, ndev, "gs_copydevice(device)");
    1.31+            return code;
    1.32+        }
    1.33+        gs_currentdevice_inline(pgs)->LockSafetyParams = saveLockSafety;
    1.34     }
    1.35-    return 0;
    1.36+    return code;
    1.37 }
    1.38 
    1.39 /* Close a device.  The client is responsible for ensuring that */