Stay-open applet - problems on quitting
Stay-open applet - problems on quitting
- Subject: Stay-open applet - problems on quitting
- From: Richard Morton <email@hidden>
- Date: Thu, 13 Nov 2003 12:41:15 +1100
Greetings,
I'm working on a stay-open applet which is causing me grief when
quitting. It's a long story & has taken a lot of debugging to nail
down, but basically what I've discovered is that when the app is quit
via Cmd-q, it enters its 'quit' handler immediately, regardless of
whatever else it's doing. This is happening under OS10.2.6, AS1.9.1.
Where it bites me is if it's asked to quit when in the middle of
executing its 'idle' routines, which can take some time. It appears to
stop what it's doing, execute 'quit' then go back to where it was in
the idle routines. My quit handler zeros out the variables the idle
handler was using, so the idle handler then errors out.
My questions are:
Is this the way it's supposed to work?
If yes, then why?
Either way, can anyone suggest a robust method for dealing with the
behaviour?
I know I can set flags, but I'm not sure it's the best way & haven't
yet found the correct spot for them either. Checking whether the
variables have been initialised seems like a kludge - if it errors
during initialisation they won't be set, so I'd need an extra trap for
that. It also doesn't strike me as a way of dealing with it close
enough to the problem - I'd like to find a more general solution if
possible.
FWIW, I've included some of the debugging info & handlers below.
A normal run looks like this:
3:07:07 PM inits(): Success. 'taskList' is 3 -- this is called from
'run'
3:07:07 PM run: Success
3:07:08 PM mains(): Success. 'taskList' is 3 -- this is called from
'idle'
3:07:08 PM idle: Success
3:07:09 PM cleanUps(): Success. 'taskList' is 0 -- this is called from
'quit'
3:07:09 PM quit: Success
The troublesome behaviour looks like this:
3:07:22 PM inits(): Success. 'taskList' is 3 -- this is called from
'run'
3:07:22 PM run: Success
3:07:22 PM mains(): Success. 'taskList' is 3 -- this is called from
'idle'
3:07:22 PM idle: Success
3:07:23 PM cleanUps(): Success. 'taskList' is 0 -- this is called from
'quit'
3:07:23 PM quit: Success
3:07:23 PM idle: Error - see other log -- ** 'idle' finishes (&
errors) after 'quit' has executed **
3:07:25 PM quit: Error - see other log
The idle handler errors the last time because it needs a list -
taskList - which was zeroed by cleanups() the first time 'quit' was
executed.
The relevant handlers (including debugging code) are:
on run
try
inits() -- initialisation routines
writeDebugLog("run", "Success") -- writes to a debugging log
on error errStr number errNum
writeDebugLog("run", "Error - see other log") -- writes to a
debugging log
writeDebugErrLog("run", errStr, errNum) -- writes to a debugging log
fatalErr for (scrIDstr & "'s run handler") from {errStr, errNum} --
displays a dialog
quit
end try
end run
on idle
try
mains()
writeDebugLog("idle", "Success") -- writes to a debugging log
return idleInterval -- a property (set to 1) not changed by any
routine
on error errStr number errNum
writeDebugLog("idle", "Error - see other log") -- writes to a
debugging log
writeDebugErrLog("idle", errStr, errNum) -- writes to a debugging log
fatalErr for (scrIDstr & "'s idle handler") from {errStr, errNum} --
displays a dialog
quit
end try
end idle
on quit
try
cleanUps()
writeDebugLog("quit", "Success") -- writes to a debugging log
on error errStr number errNum
writeDebugLog("quit", "Error - see other log") -- writes to a
debugging log
writeDebugErrLog("quit", errStr, errNum) -- writes to a debugging log
fatalErr for (scrIDstr & "'s quit handler") from {errStr, errNum} --
displays a dialog
end try
continue quit
end quit
Any thoughts would be appreciated. Apologies for the long post.
iDill
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.