> On May 13, 2014, at 13:03 , Trygve Inda <cocoa...@xericdesign.com> wrote: > >> NSAppleEventDescriptor *appleEvent = [NSAppleEventDescriptor >> appleEventWithEventClass: kMyAEClass >> eventID: kMyAEEventID >> targetDescriptor: targetDescriptor >> returnID: kAutoGenerateReturnID >> transactionID: kAnyTransactionID]; > >> AESendMessage([appleEvent aeDesc], NULL, kAENoReply | kAENeverInteract, >> kAEDefaultTimeout); > > What memory model? ARC? > > You’re getting back back a NSAppleEventDescriptor with +0 semantics, which > means (if ARC) it’s going to be locally retained, then released when it goes > out of scope (possibly a scope optimized optimized to the last reference). > > What you’re passing to AESendMessage is an interior pointer (‘aeDesc’ is > marked NS_RETURNS_INNER_POINTER in the headers). AFAIK that keeps the > underlying object alive *in the calling code* long enough for the interior > pointer to be passed safely into the called function, but no longer. > > In particular, I don’t know that the interior pointer can be assumed to be > valid for the entire length of the called function’s execution. Of course, > there’d have to be asynchronous activity (or perhaps a autorelease pool drain > inside the called function) for this to matter, but since you’re not asking > for a reply, that seems possible. > > So, my theory: memory management bug in your code. A simple way to test this > would be to put ‘[appleEvent self];’ after the AESendMessage call, and see if > the problem goes away. >
One thing I have noticed... I am calling AESendMessage to send a new AppleEvent from a handler for another AppleEvent Eg in the handler for event of type EventA, I am using AESendMessage to send EventB If instead I use an NSOperationQueue to send EventB (adding a operation to the queue in the responder for EventA), then everything works. I am guessing that AESendMessage does not like being called from within an AppleEvent handler, but it works most of the time so I am not sure. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com