]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/sg_netChannel.cxx
Drop explicit SDK setting on Mac
[simgear.git] / simgear / io / sg_netChannel.cxx
index be8299f7658e735ed5c69f86df7679953379b9b5..1561e8de464bbbc83413915f1b53d82ec2367727 100644 (file)
@@ -251,6 +251,11 @@ NetChannelPoller::removeChannel(NetChannel* channel)
     assert(channel->poller == this);
     channel->poller = NULL;
     
+    // portability: MSVC throws assertion failure when empty
+    if (channels.empty()) {
+        return;
+    }
+
     ChannelList::iterator it = channels.begin();
     for (; it != channels.end(); ++it) {
         if (*it == channel) {
@@ -273,7 +278,6 @@ NetChannelPoller::poll(unsigned int timeout)
     int nreads = 0 ;
     int nwrites = 0 ;
     int nopen = 0 ;
-    NetChannel* ch;
     
     ChannelList::iterator it = channels.begin();
     while( it != channels.end() )
@@ -281,6 +285,9 @@ NetChannelPoller::poll(unsigned int timeout)
         NetChannel* ch = *it;
         if ( ch -> should_delete )
         {
+            // avoid the channel trying to remove itself from us, or we get
+            // bug http://code.google.com/p/flightgear-bugs/issues/detail?id=1144
+            ch->poller = NULL;
             delete ch;
             it = channels.erase(it);
             continue;
@@ -320,14 +327,14 @@ NetChannelPoller::poll(unsigned int timeout)
 
     for ( int i=0; reads[i]; i++ )
     {
-      ch = (NetChannel*)reads[i];
+      NetChannel* ch = (NetChannel*)reads[i];
       if ( ! ch -> closed )
         ch -> handleReadEvent();
     }
 
     for ( int i=0; writes[i]; i++ )
     {
-      ch = (NetChannel*)writes[i];
+      NetChannel* ch = (NetChannel*)writes[i];
       if ( ! ch -> closed )
         ch -> handleWriteEvent();
     }