[racket] how to tell, or trigger, on when an object is ready in tool on on startup

From: Stephen De Gabrielle (stephen.degabrielle at acm.org)
Date: Tue Jul 27 03:54:22 EDT 2010

Hi,

I'm working on the tools facilities to build extensions for DrRacket,
and I'm having some trouble;

I think I'm getting the ''send: target is not an object: #<undefined>
for method: is-shown?
'' error on startup because the frame, tabs or text% is not yet
finished starting up.

I'd appreciate any help on how to run my method when DrRacket is ready?

Cheers,

Stephen


-- 
send: target is not an object: #<undefined> for method: is-shown?

 === context ===
/Applications/Racket
v5.0/collects/racket/private/class-internal.rkt:4543:0: obj-error
/Applications/Racket
v5.0/collects/racket/private/class-internal.rkt:3786:0:
find-method/who
/Applications/Racket
v5.0/collects/gui-debugger/debug-tool.rkt:1404:10:
check-current-language-for-debugger method in
...ugger/debug-tool.rkt:1048:8
/Applications/Racket
v5.0/collects/gui-debugger/debug-tool.rkt:1393:10: on-tab-change
method in ...ugger/debug-tool.rkt:1048:8
/Applications/Racket v5.0/collects/drracket/syncheck.rkt:1027:8:
on-tab-change method in ...rracket/syncheck.rkt:1019:6
/Applications/Racket
v5.0/collects/drracket/private/module-language-tools.rkt:58:6:
on-tab-change method in ...e-language-tools.rkt:49:4
/Applications/Racket v5.0/collects/drracket/private/tracing.rkt:168:6:
on-tab-change method in .../private/tracing.rkt:163:4
/Applications/Racket v5.0/collects/drracket/private/debug.rkt:1580:6:
on-tab-change method in ...et/private/debug.rkt:1506:4
/Applications/Racket v5.0/collects/drracket/private/unit.rkt:2847:8:
change-to-tab method in ...ket/private/unit.rkt:1419:6
/Applications/Racket v5.0/collects/drracket/private/unit.rkt:2817:10: core
/Applications/Racket v5.0/collects/racket/private/map.rkt:45:11: for-each
/Applications/Racket v5.0/collects/cosmonaut/tabs.rkt:26:6
/Applications/Racket
v5.0/collects/racket/private/class-internal.rkt:3596:0:
continue-make-super
/Applications/Racket v5.0/collects/gui-debugger/debug-tool.rkt:1048:8
/Applications/Racket
v5.0/collects/racket/private/class-internal.rkt:3596:0:
continue-make-super
/Applications/Racket v5.0/collects/macro-debugger/tool.rkt:118:6
...


--

#lang racket/gui
(require racket/class
         framework
         racket/unit
         racket/path
         drracket/tool)

(preferences:set-default
 'ProjectManager:tabs "/Users/spdegabrielle/tabs.sp"
 ; (path->string (build-path (find-system-path 'home-dir) "tabs.sp"))
 string?)

(provide tool@)
(define tool@
  (unit
    (import drracket:tool^)
    (export drracket:tool-exports^)
    (define (phase1) (void))
    (define (phase2) (void))
    ;
    ;    (define tab-mixin
    ;      (mixin ()()
    ;        (super-new)
    ;        ))
    (define (save/load-tabs-mixin super%)
      (class super%
        (inherit open-in-new-tab get-tabs)

        ;        ;; 'ProjectManager:tabs ; path to tabs file
        (field (saved-tabs-file (string->path "/Users/spdegabrielle/tabs.sp")))
                                 ;(preferences:get 'ProjectManager:tabs))))
        ;
        ;; save-tabs : out-file tabs -> void
        (define/private (save-tabs-file out-file tabs)
          (call-with-output-file out-file; saved-tabs-file-path
            (lambda (i) (write tabs i))
            #:exists 'replace))
        ;
        ;; each-tab -> list of files
        ;; return the paths for all tabs that have one
        (define/private (get-tab-files)
          (map path->string
               (filter (lambda (filename) filename)
                       (map
                        (λ (t) (send (send t get-defs) get-filename))
                        (get-tabs)))))
        ;
        (define (save-tabs-to-file-on-exit-callback)
          (save-tabs-file saved-tabs-file (get-tab-files)))

        ;
        (super-new)
        ;
        ;; reload-tab-from-file : in-file -> void
        (define/private (reload-my-tabs-from-file tabs-file)
          (let ((list-of-files (call-with-input-file tabs-file read)))
            (for-each (λ (f) (open-in-new-tab f)) list-of-files)))

        ;; get-tab-filename a-drscheme:unit:tab? -> (or/c path-string? false/c)
        ;; return #f if tab has no filename
        (define (get-tab-filename tab)
          (send (send tab get-defs) get-filename))

        (reload-my-tabs-from-file saved-tabs-file)

        (exit:insert-on-callback save-tabs-to-file-on-exit-callback)
        ))

    ;   (drracket:get/extend:extend-tab tab-mixin)
    (drracket:get/extend:extend-unit-frame save/load-tabs-mixin)
    ))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tabs.rkt
Type: application/octet-stream
Size: 2448 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100727/47ad9358/attachment.obj>

Posted on the users mailing list.