Fixed leak of event objects on OS X.
This commit is contained in:
parent
01fe5fb0a3
commit
f0a5d3162e
|
@ -34,7 +34,10 @@ COSXEventQueueBuffer::COSXEventQueueBuffer() :
|
||||||
|
|
||||||
COSXEventQueueBuffer::~COSXEventQueueBuffer()
|
COSXEventQueueBuffer::~COSXEventQueueBuffer()
|
||||||
{
|
{
|
||||||
setOSXEvent(NULL);
|
// release the last event
|
||||||
|
if (m_event != NULL) {
|
||||||
|
ReleaseEvent(m_event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -47,10 +50,16 @@ COSXEventQueueBuffer::waitForEvent(double timeout)
|
||||||
IEventQueueBuffer::Type
|
IEventQueueBuffer::Type
|
||||||
COSXEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID)
|
COSXEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID)
|
||||||
{
|
{
|
||||||
EventRef carbonEvent = NULL;
|
// release the previous event
|
||||||
OSStatus error = ReceiveNextEvent(0, NULL, 0.0, true, &carbonEvent);
|
if (m_event != NULL) {
|
||||||
setOSXEvent(carbonEvent);
|
ReleaseEvent(m_event);
|
||||||
|
m_event = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the next event
|
||||||
|
OSStatus error = ReceiveNextEvent(0, NULL, 0.0, true, &m_event);
|
||||||
|
|
||||||
|
// handle the event
|
||||||
if (error == eventLoopQuitErr) {
|
if (error == eventLoopQuitErr) {
|
||||||
event = CEvent(CEvent::kQuit);
|
event = CEvent(CEvent::kQuit);
|
||||||
return kSystem;
|
return kSystem;
|
||||||
|
@ -113,12 +122,3 @@ COSXEventQueueBuffer::deleteTimer(CEventQueueTimer* timer) const
|
||||||
{
|
{
|
||||||
delete timer;
|
delete timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
COSXEventQueueBuffer::setOSXEvent(EventRef event)
|
|
||||||
{
|
|
||||||
if (m_event != NULL) {
|
|
||||||
ReleaseEvent(m_event);
|
|
||||||
}
|
|
||||||
m_event = RetainEvent(event);
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,9 +33,6 @@ public:
|
||||||
newTimer(double duration, bool oneShot) const;
|
newTimer(double duration, bool oneShot) const;
|
||||||
virtual void deleteTimer(CEventQueueTimer*) const;
|
virtual void deleteTimer(CEventQueueTimer*) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
void setOSXEvent(EventRef event);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRef m_event;
|
EventRef m_event;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue