summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2012-06-12 15:36:33 +0000
committerManolo Gouy <Manolo>2012-06-12 15:36:33 +0000
commit3ce92f408f22028d2f70169e2604fc2d8e82704e (patch)
tree47788e2800a8306d585518404d0f594957635d71 /src
parent25b66914d5d798eb858c417e3101164c99e6386a (diff)
Fixed STR#2848: Mac OS: close putative memory leak when detaching child threads.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9588 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index fcbdb2f04..0a18c5496 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -326,8 +326,6 @@ void DataReady::HandleData(fd_set& r, fd_set& w, fd_set& x)
void* DataReady::DataReadyThread(void *o)
{
DataReady *self = (DataReady*)o;
- NSAutoreleasePool *localPool;
- localPool = [[NSAutoreleasePool alloc] init];
while ( 1 ) { // loop until thread cancel or error
// Thread safe local copies of data before each select()
self->DataLock();
@@ -358,12 +356,14 @@ void* DataReady::DataReadyThread(void *o)
{ return(NULL); } // just exit
DEBUGMSG("CHILD THREAD: DATA IS READY\n");
NSPoint pt={0,0};
+ NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined location:pt
modifierFlags:0
timestamp:0
windowNumber:0 context:NULL
subtype:FLTKDataReadyEvent data1:0 data2:0];
[NSApp postEvent:event atStart:NO];
+ [localPool release];
return(NULL); // done with thread
}
}
@@ -1280,6 +1280,9 @@ void fl_open_display() {
selector:@selector(anyWindowWillClose:)
name:NSWindowWillCloseNotification
object:nil];
+ // necessary for secondary pthreads to be allowed to use cocoa,
+ // especially to create an NSAutoreleasePool.
+ [NSThread detachNewThreadSelector:nil toTarget:nil withObject:nil];
}
}