Bug 687280 - grestore sometimes restores distiller parameters
Summary: grestore sometimes restores distiller parameters
Status: RESOLVED WONTFIX
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Interpreter (show other bugs)
Version: master
Hardware: PC Windows 2000
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-29 21:39 UTC by SaGS
Modified: 2013-06-25 12:24 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SaGS 2004-01-29 21:39:20 UTC
If setpagedevice and setdistillerparams are called (in this order) 
after gsave, then the corresponding grestore will restore the 
distiller parameters (and it shoudn't). The PostScript fragment at
the end of this bug report shows the problem (it also shows the 
problem in bug #687271).

Note: The root cause for the wrong behaviour of distiller parameters 
(bugs #563287, #607425, #687271, and this one) is that these parameters 
are not, but are implemented as, page device parameters. On the other 
hand, I agree that managing these parameters at the device level is more 
elegant (read: object-oriented), especially given the large number of 
very different drivers in GhostScript. I also agree that the interface 
used by setpagedevice may be used to let the driver know of distiller 
parameters changes.

-------

%!PS

false setglobal

/crlf {
    (
) print
} def

/buf10 10 string def
/wr10 {		% val --
    (        ) buf10 copy pop
    buf10 cvs pop
    buf10 print
} def

/maxindent (                              ) def
/i 0 def
/i++ { /i i 2 add store } def
/i-- { /i i 2 sub store } def

/crtval null def
/setval {	% msg newval --
    () wr10 dup wr10
    i 0 gt { maxindent 0 i getinterval print} if
    exch print crlf
    /crtval 1 index store
    1 dict dup /AutoFilterColorImages 4 -1 roll put setdistillerparams
} def
/prtval {	% msg --
    crtval wr10 currentdistillerparams /AutoFilterColorImages get wr10
    i 0 gt {maxindent 0 i getinterval print} if
    print crlf
} def


a4

    (expected) wr10 (found)    wr10 (message) 
print                                  crlf
    (--------) wr10 (--------) wr10 (----------------------------------------) 
print crlf
    (Will "save" ...) false setval
    save i++
	(... did "save") prtval
	0 0 moveto 612 792 lineto stroke
	(Will "gsave" ...) true setval
	gsave i++
	    (... did "gsave", will "setpagedevice" ...) prtval
	    <</PageSize [100 100]>> setpagedevice
	    (... did "setpagedevice") prtval
	    (Changing value after save-gsave-setpagedevice) false setval
	i-- grestore
	(... did "grestore", will "setpagedevice" again ...) prtval
	<</PageSize [50 100]>> setpagedevice
	(... did "setpagedevice", preparing to "restore"...) true setval
    i-- restore
    (... did "restore") prtval

showpage

-------
Comment 1 Jack Moffitt 2004-10-24 20:57:42 UTC
I get Error: /undefined in /setdistillerparams with the test sample, but I
recall have reproduced this at one time and/or discussing it on the call. 
Assigning to Ray for further investigation.
Comment 2 SaGS 2004-10-25 00:03:14 UTC
Distiller-related operators are visible only when the current device is 
pdfwrite ("where" is patched to check the current device and hide them if 
necessary). With other devices, the error mentioned in comment #1 is normal.
Comment 3 Timothy Osborn 2007-08-15 05:26:23 UTC
I have verified that this situation still occurs in the latest build (r8191).
The output I see when I run this with the following arguments:

gs -sDEVICE=pdfwrite -sOutputFile=test.pdf -r72 687280.ps

(where 687280.ps is the PS from comment #0) is as follows:

expectedfound   message
--------------------------------------------------------
        false   Will "save" ...
false   false     ... did "save"
        true      Will "gsave" ...
true    true        ... did "gsave", will "setpagedevice" ...
true    true        ... did "setpagedevice"
        false       Changing value after save-gsave-setpagedevice
false   true      ... did "grestore", will "setpagedevice" again ...
        true      ... did "setpagedevice", preparing to "restore"...
false   true    ... did "restore"

Comment 4 Shailesh Mistry 2011-07-11 19:32:59 UTC
Bug still reproducible in Ghostscript 9.03
Comment 5 Ken Sharp 2013-06-25 12:24:38 UTC
See bug #687271

Closing as wontfix because frankly its been 9 years, nobody has done anything about this, and its yet to present an actual problem.