[Not part of build.] Fix for bugzilla #136063, override operator new/delete for thread-safety, remove carbon timer from main event loop before processing. r=bnesse, sr=sfraser
This commit is contained in:
Родитель
d58306dcf5
Коммит
006a844161
|
@ -991,6 +991,16 @@ void MRJContext::setProxyInfoForURL(char * url, JMProxyType proxyType)
|
|||
|
||||
#if TARGET_CARBON
|
||||
|
||||
void* TimedMessage::operator new(size_t n)
|
||||
{
|
||||
return (void*) NewPtr(n);
|
||||
}
|
||||
|
||||
void TimedMessage::operator delete(void* ptr)
|
||||
{
|
||||
DisposePtr(Ptr(ptr));
|
||||
}
|
||||
|
||||
TimedMessage::TimedMessage()
|
||||
: mTimerUPP(NULL)
|
||||
{
|
||||
|
@ -1006,12 +1016,13 @@ OSStatus TimedMessage::send()
|
|||
{
|
||||
EventLoopTimerRef timerRef;
|
||||
return ::InstallEventLoopTimer(::GetMainEventLoop(), 0, 0,
|
||||
mTimerUPP, this, &timerRef);
|
||||
// XXX does this leak timers? should the timer be released right here?
|
||||
mTimerUPP, this, &timerRef);
|
||||
}
|
||||
|
||||
pascal void TimedMessage::TimedMessageHandler(EventLoopTimerRef inTimer, void *inUserData)
|
||||
{
|
||||
// prevent this timer from ever firing again.
|
||||
RemoveEventLoopTimer(inTimer);
|
||||
TimedMessage* message = reinterpret_cast<TimedMessage*>(inUserData);
|
||||
message->execute();
|
||||
delete message;
|
||||
|
|
|
@ -39,8 +39,11 @@
|
|||
#include <CarbonEvents.h>
|
||||
|
||||
class TimedMessage {
|
||||
EventLoopTimerUPP mTimerUPP;
|
||||
public:
|
||||
// Override operator new/delete for thread-safe memory allocation.
|
||||
void* operator new(size_t n);
|
||||
void operator delete(void* ptr);
|
||||
|
||||
TimedMessage();
|
||||
virtual ~TimedMessage();
|
||||
|
||||
|
@ -49,5 +52,5 @@ public:
|
|||
|
||||
private:
|
||||
static pascal void TimedMessageHandler(EventLoopTimerRef inTimer, void *inUserData);
|
||||
EventLoopTimerUPP mTimerUPP;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче