• 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: CGEventCreateKeyboardEvent just crashes?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGEventCreateKeyboardEvent just crashes?!?


  • Subject: Re: CGEventCreateKeyboardEvent just crashes?!?
  • From: Eric Schlegel <email@hidden>
  • Date: Wed, 4 Oct 2006 07:37:33 -0700


On Oct 4, 2006, at 4:56 AM, Ondra Cada wrote:

Hi all,

anybody can use CGEventCreateKeyboardEvent?

I create the simplest project possible. Call the function exactly the way it's documented. And always got a nice small SIGBUS...

Here's my source:

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSLog(@"Hello, Apple World! What's there with them blasted events?!?");
CGEventRef er=CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, true); // directly from docs
NSLog(@"actually, got event ref at %x. Bye.",er);
[pool release];
return 0;
}

The problem is that CGEventCreateKeyboardEvent is supposed to use the default event source if you pass NULL for the first param, but a bug in the Tiger implementation caused it to not initialize the default source soon enough and so it crashed when attempting to use it. This has been fixed in Leopard. The recommended workaround is to call CFRelease(CGEventCreate(NULL)) before calling the other APIs.


-eric


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Now CGEventCreateKeyboardEvent just doesn't work...
      • From: Ondra Cada <email@hidden>
References: 
 >CGEventCreateKeyboardEvent just crashes?!? (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: real memory usage - is this even possible?
  • Next by Date: Re: Two lines in a single table column
  • Previous by thread: Re: CGEventCreateKeyboardEvent just crashes?!?
  • Next by thread: Now CGEventCreateKeyboardEvent just doesn't work...
  • Index(es):
    • Date
    • Thread