[AppleScript+Cocoa] NSScriptCommand misbehaving?
[AppleScript+Cocoa] NSScriptCommand misbehaving?
- Subject: [AppleScript+Cocoa] NSScriptCommand misbehaving?
- From: j o a r <email@hidden>
- Date: Mon, 3 Feb 2003 16:51:23 +0100
Problem:
Executing a script command crashes the receiver if it doesn't respond
to the selector.
(Crash log at the end of this message).
Background:
In our application AppleScript is implemented as a plugin that is
loaded when the
application is launched. The AppleScript plugin loads a category to
NSApplication
with the methods defined in our script suite.
The launch process can be interrupted for a couple of reasons, and in
these cases
the user is presented with an alert panel, prompting for input. If the
alert is posted
*before* the AppleScript plugin is loaded the receiver will not
respond to the method
specified in the script suite.
Discussion:
First off I'm a bit surprised that the AppleEvent is allowed to run
while the our
application is modal to the alert panel, but perhaps this is as it
should?
In any case, according to the documentation the script command is
supposed to
check if the receiver of the command responds to the selector before
sending the
message (From: Overview of Programming Topic: Scriptable Applications):
Executing a Script Command
Once the Apple event translator (shown in Figure 2) has created and
prepared a script command, it executes it in a series of steps:
<snip>
2) It determines which method to use for executing the command. It
first looks in the class description of the receiver to see if it has
specified a selector for the command. If it doesn't, it selects the
default implementation for the command.
<snip>
This does not seem to be the case? The "default implementation" of
NSScriptCommand is supposed to do nothing, if I read the docs
correctly, but I don't think that it is ever called.
I can think of ways to work around this problem, but if this is
considered a bug, I would like to report it to Apple before I move on.
j o a r
// Crash log
Date/Time: 2003-02-03 08:08:38 +0100
OS Version: 10.2.3 (Build 6G30)
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x0000000c
Thread 0 Crashed:
#0 0x90800494 in +[NSInvocation newInvocationWithMethodSignature:]
#1 0x90821450 in +[NSInvocation invocationWithMethodSignature:]
#2 0x9088fb1c in -[NSScriptCommand executeCommand]
#3 0x908938c4 in -[NSScriptingAppleEventHandler
handleAppleEvent:withReplyEvent:]
#4 0x908585ac in -[NSAppleEventManager
dispatchRawAppleEvent:withRawReply:handlerRefCon:]
#5 0x908b76c0 in _globalAEEventHandler
#6 0x91b56570 in _Z20aeDispatchAppleEventPK6AEDescPS_mPh
#7 0x91b590cc in _Z25dispatchEventAndSendReplyPK6AEDescPS_
#8 0x91b56478 in aeProcessAppleEvent
#9 0x96a82c04 in AEProcessAppleEvent
#10 0x9308da78 in _DPSNextEvent
#11 0x9309fb04 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#12 0x93143928 in -[NSApplication _realDoModalLoop:peek:]
#13 0x931bb978 in -[NSApplication runModalForWindow:]
#14 0x933bb99c in _NXDoLocalRunAlertPanel
#15 0x933726c4 in NSRunAlertPanel
#16 0x0008f710 in -[MainController initializeMyApp]
#17 0x907fd32c in __NSFireDelayedPerform
#18 0x901632f0 in __CFRunLoopDoTimer
#19 0x90148e48 in __CFRunLoopRun
#20 0x90180fe4 in CFRunLoopRunSpecific
#21 0x969a36a0 in RunCurrentEventLoopInMode
#22 0x969b34c8 in ReceiveNextEventCommon
#23 0x969da584 in BlockUntilNextEventMatchingListInMode
#24 0x9308d8ac in _DPSNextEvent
#25 0x9309fb04 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#26 0x930b15e4 in -[NSApplication run]
#27 0x9315f6b8 in NSApplicationMain
#28 0x0011c578 in main
#29 0x00004538 in _start
#30 0x000043b8 in start
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.