File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -365,6 +365,23 @@ the state transitions / contracts are:
365365 copy
366366 value)))
367367
368+ ;; same-pref-value? : sym any any -> boolean
369+ ;; compares two preference values; if they are
370+ ;; eq? then they are the same. Otherwise, they
371+ ;; are the same if they marshall to equal? values
372+ (define (same-pref-value? p val1 val2)
373+ (cond
374+ [(eq? val1 val2) #t ]
375+ [else
376+ (define pref-state (find-layer p))
377+ (define marshall-unmarshall (preferences:layer-marshall-unmarshall pref-state))
378+ (define un/marshaller (hash-ref marshall-unmarshall p #f ))
379+ (cond
380+ [un/marshaller
381+ (define marsh (un/marshall-marshall un/marshaller))
382+ (equal? (marsh val1) (marsh val2))]
383+ [else #f ])]))
384+
368385(define (preferences:restore-defaults)
369386 (let loop ([prefs-state (preferences:current-layer)])
370387 (when prefs-state
@@ -387,8 +404,14 @@ the state transitions / contracts are:
387404 [else sofar]))))
388405
389406(define (preferences:restore-prefs-snapshot snapshot)
390- (multi-set (map car (preferences:snapshot-x snapshot))
391- (map cdr (preferences:snapshot-x snapshot)))
407+ (define items
408+ (for/list ([key+val (in-list (preferences:snapshot-x snapshot))]
409+ #:unless
410+ (same-pref-value? (car key+val)
411+ (cdr key+val)
412+ (preferences:get (car key+val))))
413+ key+val))
414+ (multi-set (map car items) (map cdr items))
392415 (void))
393416
394417(begin-for-doc
You can’t perform that action at this time.
0 commit comments