(let ((cursor (text-widget-cursor-ink widget)))
(if cursor
(fix-ink-remove! cursor)))
- (and-let* ((drawing (text-widget-override-drawing widget))
- (ink (car (fix-drawing-display-list drawing)))
- ((text-ink? ink))
- (layout (text-ink-pango-layout ink)))
- (gobject-unref! layout))
+ (let ((drawing (text-widget-override-drawing widget)))
+ (and drawing
+ (let ((ink (car (fix-drawing-display-list drawing))))
+ (and (simple-text-ink? ink)
+ (let ((layout (simple-text-ink-pango-layout ink)))
+ (and layout
+ (gobject-unref! layout)))))))
unspecific)
(define-method fix-widget-realize-callback ((widget <text-widget>))
(%trace3 ";\t redraw-line! "line" from "(line-ink-start line)
" ("x","y") with "pango-layout"\n")
- (layout-line! line pango-layout)
+ (without-interrupts
+ (lambda ()
+ (%layout-line! line pango-layout)))
(pango-layout-get-pixel-extents
pango-layout
(lambda (width height)
(define image-buffer-size (* 50 1024))
(define image-buffer (string-allocate image-buffer-size))
-(define-integrable image-results substring-image-results)
-(define (layout-line! line pango-layout)
+(define (%layout-line! line pango-layout)
+ ;; This must run without-interrupts because it uses image-buffer.
+ ;; An async expose event might otherwise fubar it.
(let* ((drawing (fix-ink-drawing line))
(buffer (buffer-drawing-buffer drawing))
(group (buffer-group buffer))
(buffer-drawing-char-image-strings drawing)
(lambda (text-index image-index)
(if (fix:= image-index max-image-size)
- (warn ";layout-line!: long paragraph"))
+ (warn ";%layout-line!: long paragraph"))
(set-mark-index! (line-ink-end line) text-index)
;; Run Pango on buffer.
layout))
;; Do not (call-next-method ink). There is no <text-ink> method.
- (if (unchanged? ink)
- (or (line-ink-cached-pango-layout ink)
- ;; When executed by the expose handler, this already runs
- ;; without-interrupts. However there are other places
- ;; (e.g. redraw-cursor) where this could be called. Ensure
- ;; that the async. expose handlers do not start frobbing the
- ;; pango-layout cache until we are done here.
- (without-interrupts
- (lambda ()
- (let ((layout (or (salvage-pango-layout ink)
- (cache-pango-layout ink))))
- (layout-line! ink layout)
- layout))))
- (begin
- (outf-error ";text-ink-pango-layout: punted "ink"\n")
- #f)))
+ (cond ((fix:zero? (fix-rect-height (fix-ink-extent ink)))
+ ;; An expose event can arrive between adding a new line to
+ ;; the drawing and laying it out (see add-line in
+ ;; update-drawing). If the dimensions (any) are zero, punt.
+ #f)
+ ((unchanged? ink)
+ (or (line-ink-cached-pango-layout ink)
+ ;; When executed by the expose handler, this already runs
+ ;; without-interrupts. However there are other places
+ ;; (e.g. redraw-cursor) where this could be called. Ensure
+ ;; that the async. expose handlers do not start frobbing the
+ ;; pango-layout cache until we are done here.
+ (without-interrupts
+ (lambda ()
+ (let ((layout (or (salvage-pango-layout ink)
+ (cache-pango-layout ink))))
+ (%layout-line! ink layout)
+ layout)))))
+ (else
+ (outf-error ";text-ink-pango-layout: punted "ink"\n")
+ #f)))
(define (clear-cached-pango-layout line)
;; This probably aught to be done without-interrupts, since it