Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: eventNotHandledErr vs noErr
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: eventNotHandledErr vs noErr



Hello list,

I've been watching this thread for a while, and I must say I know one
reason to use
CallNextEventHandler(). Maybe someone knows more reasons, but I use it
for this purpose.
I have a threaded app where the MPTask uses DrawPicture().
DrawPicture() is NOT threadsafe. I periodically display results from
that thread in an ImageWell (to be nice in the Aqua GUI). I can block
my calls to the refresh using an MPCriticalRegion, but, I can not
prevent the control from "feeling to draw itself " according to some
update event, or when the update event latency is too long compared to
the processing time in which the MPTask spends in DrawPicture. [making
a thumbnail of a 2000x1000 pixel image].

So, I installed this an EventHandler on that ImageWell control to
prevent it from drawing if a thread was inside DrawPicture(). The code
below is what that eventhandler does.


case kEventControlDraw:
if (::MPEnterCriticalRegion( thesafe, kDurationImmediate ) == noErr ) {
eventHandled=::CallNextEventHandler(inHandlerRef,inEvent);
}
else {
eventHandled = noErr;
}
::MPExitCriticalRegion( thesafe );
break;

So, I trap the event kEventControlDraw to prevent the ImageWell from
darwing at an unsafe time, otherwise I call its eventhandler so it will
draw.

// Totte
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: eventNotHandledErr vs noErr (From: Mike Kluev <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.