I’m not sure what’s happening there. I just opened a new document (from the Enhanced Applet template), saved it, ran it, opened the About menu, closed it again, without any crash.
It seems related to status bar item. Here is an example that quits when you save as enhanced and goto the about menu.
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
property NSStatusBar : a reference to current application's NSStatusBar
property NSVariableStatusItemLength : a reference to current application's NSVariableStatusItemLength
property NSMenu : a reference to current application's NSMenu
property NSMenuItem : a reference to current application's NSMenuItem
property theStatusItem : missing value
set theList to {"Fruit", {"Apple", "Banana"}, "Vegetable", {"Lettuce", "Tomato", {"Fresh", "Salty"}}, "", "Quit"}
my performSelectorOnMainThread:"menuBarTest:" withObject:(current application's NSVariableStatusItemLength) waitUntilDone:true
theStatusItem's setTitle:"Food"
theStatusItem's setHighlightMode:true
set aMenu to NSMenu's alloc()'s init()
set {aCount, prevMenuItem} to {10, ""}
makeNewSubMenu(theList, aCount, aMenu)
theStatusItem's setMenu:aMenu
on makeNewSubMenu(aList, aCount, aMenu)
repeat with i in aList
set j to contents of i
if j is equal to "" then
set aMenuItem to (NSMenuItem's separatorItem())
(aMenu's addItem:aMenuItem)
else if ((class of j) as string) = "list" then
--Generate Submenu
set subMenu to NSMenu's new()
(aMenuItem's setSubmenu:subMenu)
my makeNewSubMenu(j, aCount, subMenu)
else
set aMenuItem to (NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
(aMenuItem's setTag:aCount)
(aMenuItem's setTarget:me)
(aMenu's addItem:aMenuItem)
set aCount to aCount + 10
copy aMenuItem to prevMenuItem
end if
end repeat
end makeNewSubMenu
on actionHandler:sender
set theTag to tag of sender as integer
set theTitle to title of sender as string
if theTitle is not equal to "Quit" then
display dialog (theTag as string) & " " & theTitle as string
else
NSStatusBar's systemStatusBar()'s removeStatusItem:theStatusItem
quit
end if
end actionHandler:
on menubarTest:theObject
set theStatusItem to (current application's NSStatusBar's systemStatusBar()'s statusItemWithLength:(theObject))
---return theStatusItem
end menubarTest:
It works fine here. Can you email me the file you’re testing?
I just sent. Thank you!
Were you able to reproduce? Can anyone else here test the code posted above and goto about menu and see if theirs quits when closing the window?
Yes, I can reproduce it, thanks.