Author: manolo
Date: 2011-05-31 04:20:52 -0700 (Tue, 31 May 2011)
New Revision: 8771
Log:
Fix STR #2652: Mac OS-specific bug in Fl::remove_fd().

Modified:
   branches/branch-1.3/src/Fl_cocoa.mm

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2011-05-30 21:19:43 UTC (rev 8770)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2011-05-31 11:20:52 UTC (rev 8771)
@@ -238,7 +238,7 @@
     pthread_mutex_init(&_datalock, NULL);
     FD_ZERO(&_fdsets[0]); FD_ZERO(&_fdsets[1]); FD_ZERO(&_fdsets[2]);
     _cancelpipe[0] = _cancelpipe[1] = 0;
-    _maxfd = 0;
+    _maxfd = -1;
   }
   
   ~DataReady()
@@ -304,12 +304,14 @@
 void DataReady::RemoveFD(int n, int events)
 {
   int i,j;
+  _maxfd = -1; // recalculate maxfd on the fly
   for (i=j=0; i<nfds; i++) {
     if (fds[i].fd == n) {
       int e = fds[i].events & ~events;
       if (!e) continue; // if no events left, delete this fd
       fds[i].events = e;
     }
+    if (fds[i].fd > _maxfd) _maxfd = fds[i].fd;
     // move it down in the array if necessary:
     if (j<i) {
       fds[j] = fds[i];
@@ -321,7 +323,6 @@
   /*LOCK*/  if (events & POLLIN)  FD_CLR(n, &_fdsets[0]);
   /*LOCK*/  if (events & POLLOUT) FD_CLR(n, &_fdsets[1]);
   /*LOCK*/  if (events & POLLERR) FD_CLR(n, &_fdsets[2]);
-  /*LOCK*/  if (n == _maxfd) _maxfd--;
   DataUnlock();
 }
 

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to