• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Assert trigged in -[NSEvent eventNumber]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Assert trigged in -[NSEvent eventNumber]


  • Subject: Re: Assert trigged in -[NSEvent eventNumber]
  • From: "Mattias Arrelid" <email@hidden>
  • Date: Tue, 24 Jun 2008 08:42:09 +0200

On Mon, Jun 23, 2008 at 7:24 PM, Jens Alfke <email@hidden> 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@hidden)

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:

This email sent to email@hidden

References: 
 >Assert trigged in -[NSEvent eventNumber] (From: "Mattias Arrelid" <email@hidden>)
 >Re: Assert trigged in -[NSEvent eventNumber] (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: How to get a message when RETURN is pressed in a NSTextField
  • Next by Date: Re: How to get a message when RETURN is pressed in a NSTextField
  • Previous by thread: Re: Assert trigged in -[NSEvent eventNumber]
  • Next by thread: Newbie seeks code review
  • Index(es):
    • Date
    • Thread