do even less work before queueing the callback in hopes it is guaranteed to get queued

closes PR 15317
This commit is contained in:
Robby Findler 2016-06-30 10:14:10 -05:00
parent af33c70558
commit 0b2be755e4

View File

@ -173,10 +173,23 @@
;; install-recent-items : (is-a?/c menu%) -> void? ;; install-recent-items : (is-a?/c menu%) -> void?
(define (install-recent-items menu) (define (install-recent-items menu)
;; sometimes, we get here via an on-demand callback
;; and we run out of time during the callback and
;; things go awry with the menu. So, to hack around
;; that problem, lets try to do it twice; once here
;; when we notice that things are wrong, and then once
;; in a later event callback, when we know we won't run
;; afoul of any time limits.
(do-install-recent-items menu)
(queue-callback (λ () (do-install-recent-items menu)) #f)
(void))
(define (do-install-recent-items menu)
(define recently-opened-files (define recently-opened-files
(preferences:get (preferences:get
'framework:recently-opened-files/pos)) 'framework:recently-opened-files/pos))
(define (update-menu-with-new-stuff)
(unless (menu-items-still-same? recently-opened-files menu)
(for ([item (send menu get-items)]) (send item delete)) (for ([item (send menu get-items)]) (send item delete))
(for ([recent-list-item recently-opened-files]) (for ([recent-list-item recently-opened-files])
@ -188,20 +201,7 @@
(new menu-item% (new menu-item%
[parent menu] [parent menu]
[label (string-constant show-recent-items-window-menu-item)] [label (string-constant show-recent-items-window-menu-item)]
[callback (λ (x y) (show-recent-items-window))])) [callback (λ (x y) (show-recent-items-window))])))
(unless (menu-items-still-same? recently-opened-files menu)
;; sometimes, we get here via an on-demand callback
;; and we run out of time during the callback and
;; things go awry with the menu. So, to hack around
;; that problem, lets try to do it twice; once here
;; when we notice that things are wrong, and then once
;; later, when we know we won't run afoul of any time
;; limits.
(queue-callback (λ () (update-menu-with-new-stuff)) #f)
(update-menu-with-new-stuff))
(void))
(define (recent-list-item->menu-label recent-list-item) (define (recent-list-item->menu-label recent-list-item)
(let ([filename (car recent-list-item)]) (let ([filename (car recent-list-item)])