On Mon, Jun 23, 2008 at 7:24 PM, Jens Alfke <[EMAIL PROTECTED]> wrote: > > On 23 Jun '08, at 5:21 AM, Mattias Arrelid wrote: > >> The error claim that an >> assert has failed in -[NSEvent eventNumber] - and each time this >> occured, our custom mouse tracking seemed to stop working. >> Unfortunately, I do not have access to the log at the moment. What >> would be the rightâ„¢ thing to do here? Since it isn't an exception, I >> cannot catch it myself, so I'm fumbling in the dark at the moment. > > Assertion failures *are* NSExceptions, and you can use an @catch block to > intercept them.
Ah! I did fail to read up on NSAssert - I was stuck on simple C asserts so I didn't think that long. Thanks for pointing this out. > However, they also indicate an error in your code, so of course you should > try to fix the bug instead of just ignoring the exception. The best thing to > do is to use Xcode's breakpoints window to add a breakpoint at > "objc_exception_throw" (on Leopard) or "NSRaiseError" (Tiger), and run your > code with breakpoints on until you can get the exception to occur. Then you > can look at the stack and your variables to figure out what's wrong. > > If it's one of those unpleasant bugs that only manifests when no one's > looking for it, you can build some debugging features into the app. My > MYUtilities library[1] has a module called ExceptionUtils[2] for use in > displaying backtraces of exceptions. You can use this to have any uncaught > exception pop up an alert panel containing the full backtrace. With the above fresh in my mind, I looked through the logs and found this: *** Assertion failure in -[NSEvent eventNumber], /SourceCache/AppKit/AppKit-949.33/AppKit.subproj/NSEvent.m:787 Invalid message sent to event "NSEvent: type=SysDefined loc=(333,548) time=183243.9 flags=0x100 win=0x0 winNum=0 ctxt=0xf8db subtype=7 data1=1 data2=0" Looking at the parameters, it looks like I'm trying to do something with a custom NSEvent that Apple doesn't approve. Turning on the "objc_exception_throw" breakpoint and then running the application for a few hours (phew!) caught the above mentioned exception - and much to my delight, the debugger clearly showed me why the assert was triggered; I was trying to pass the custom event to NSWindow's dragImage:at:offset:event:pasteboard:source:slideBack:. Many thank Jens! / Mattias _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
