On Thu, Oct 9, 2008 at 9:15 AM, Michiel de Hoon <[EMAIL PROTECTED]> wrote: > Hi everybody, > > According to the documentation, [NSApp stop:] will break the flow of control > out of the [NSApp run] method. While this is true, [NSApp run] doesn't > notice that [NSApp stop:] was called until some other event comes along. So > I call [NSApp stop:], nothing happens, and when I then move the mouse over > one of the application windows [NSApp run] exits. Currently my workaround is > to post a do-nothing event to NSApp to wake up the runloop: > > [NSApp stop: nil]; > NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined > location: NSMakePoint(0,0) > modifierFlags: 0 > timestamp: 0.0 > windowNumber: 0 > context: nil > subtype: 0 > data1: 0 > data2: 0]; > [NSApp postEvent: event atStart: true]; > > Then [NSApp run] exits immediately. > But there must be a better way to do this. Does anybody know what the right > way is to do this?
This sort of thing is surprisingly common. For example, autorelease pools don't get drained until an event happens: http://www.mikeash.com/?page=pyblog/more-fun-with-autorelease.html The workaround you came up with seems to be standard operating procedure for this kind of thing. I certainly don't know of a better way, and I wouldn't worry about doing what you're doing. Mike _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]