Mercurial > emacs
comparison lisp/gs.el @ 38935:b1bf1a386c78
(gs-load-image): Wait for GHOSTVIEW window property
being reset by Ghostscript. Don't kill the gs process.
From David.Kastrup@neuroinformatik.ruhr-uni-bochum.de.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 24 Aug 2001 09:40:22 +0000 |
parents | a6653fe3cbb9 |
children | 751bf57c84a1 |
comparison
equal
deleted
inserted
replaced
38934:4abf0b5b1fe3 | 38935:b1bf1a386c78 |
---|---|
151 and height of the image in pixels. WINDOW-AND-PIXMAP-ID is a string of | 151 and height of the image in pixels. WINDOW-AND-PIXMAP-ID is a string of |
152 the form \"WINDOW-ID PIXMAP-ID\". Value is non-nil if successful." | 152 the form \"WINDOW-ID PIXMAP-ID\". Value is non-nil if successful." |
153 (unwind-protect | 153 (unwind-protect |
154 (let ((file (plist-get (cdr spec) :file)) | 154 (let ((file (plist-get (cdr spec) :file)) |
155 gs | 155 gs |
156 (waiting 0)) | 156 (timeout 10)) |
157 ;; If another ghostscript is running, wait for it to complete. | 157 ;; Wait while property gets freed from a previous ghostscript |
158 ;; Two ghostscript processes running at the same time would | 158 ;; process |
159 ;; use the same window properties, and get confused. | 159 (while (and (not (zerop (length (x-window-property "GHOSTVIEW" |
160 (while (and (process-status "gs") (< waiting 10)) | 160 frame)))) |
161 (not (zerop timeout))) | |
161 (sit-for 0 100 t) | 162 (sit-for 0 100 t) |
162 (setq waiting (1+ waiting))) | 163 (setq timeout (1- timeout))) |
163 (when (process-status "gs") | 164 ;; No use waiting longer. We might want to try killing off |
164 (kill-process "gs")) | 165 ;; stuck processes, but there is no point in doing so: either |
166 ;; they are stuck for good, in which case the user would | |
167 ;; probably be responsible for that, and killing them off will | |
168 ;; make debugging harder, or they are not. In that case, they | |
169 ;; will cause incomplete displays. But the same will happen | |
170 ;; if they are killed, anyway. | |
165 (gs-set-ghostview-window-prop frame spec img-width img-height) | 171 (gs-set-ghostview-window-prop frame spec img-width img-height) |
166 (gs-set-ghostview-colors-window-prop frame pixel-colors) | 172 (gs-set-ghostview-colors-window-prop frame pixel-colors) |
167 (setenv "GHOSTVIEW" window-and-pixmap-id) | 173 (setenv "GHOSTVIEW" window-and-pixmap-id) |
168 (setq gs (apply 'start-process "gs" "*GS*" gs-program | 174 (setq gs (apply 'start-process "gs" "*GS*" gs-program |
169 (gs-options gs-device file))) | 175 (gs-options gs-device file))) |