[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rumors of dead macptrs



Dear MCL Mavens;

As usual, I'm turning to you when I have a problem that's
hard to characterize, and has "bugged" me for awhile.

I have a menu that pops up on option-click in a window
(The GUI Police need not respond; it's "temporary", I swear).
If the menu is created once and the application is saved,
there is a problem when the saved application is run. Now
option-click leads not to a menu of commands, but a
DEAD-MACPTR error.

This is easy to rationalize. When the application was
saved, MCL didn't know about this menu, so it didn't
deal with the menu object's macptr into the Mac heap,
so the old macptr is invalid in the new application.
This assumes that at save-application time, MCL recognizes
and deals with installed menus, which I suspect is not
what happens at all.

I noticed that font-menus.lisp contains the line:
(pushnew 'add-font-menus *lisp-startup-functions*).
The fn should actually be called add-fonts-menu, because
what it does is rebuild the Fonts heirarchical menu,
just in case your font mix changed since the last time
you ran your application. Anyway, using this technique
made the error go away, but, as usual, I'm still not
happy.

A formerly-perfectly-good menu containing a destined-to-
be-dead macptr still got saved in the application. I
suspect that when the popup menu vanishes (unpops) from
the screen its menu-handle slot's macptr should be
deallocated and the slot set to nil. Similarly the
menu-id slot should be set to nil.

Questions:

1. Does this mean something more should be done when the
   popup menu unpops? e.g. I don't think menu-deinstall
   is being called.

2. If my "solution" is basically correct, shouldn't a
   *save-exit-functions* fn clean up before the save,
   and what would that fn look like?

3. I had a similar problem with the HIERARCHICAL menus in
   Matt Cornell's fred-keystroke-macros; anyone know why?

4. I had a similar problem (boy I have a lot of problems)
   with a CHECK-MARK I put on a menu-item:
    (add-new-item menu "Debugging"  nil 
                  'debugging-menu-item-action
                  :menu-item-checked *debugging*)
   When the saved app started it called
   set-menu-item-check-mark on a dead MacPtr in a tight
   loop breaking a mile a minute. Does this mean check-mark
   menu items have to be removed before a save? Doesn't
   seem likely, but I haven't solved it.
   
5. If the line above from font-menus.lisp allocates a
   macptr, why is it using *lisp-startup-functions* vice
   def-load-pointers? (MCL Reference p651).

6. Anyone got a meaty example of def-load-pointers usage?

Tx,
_Steve