]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/socket.cpp
add event.Skip() in EVT_CONTEXT_MENU handler
[wxWidgets.git] / src / common / socket.cpp
index aba83174a42654305ee3cb51f8655c1cc7fa37a4..9da07423a367d996f44edbb2f8aa68b729553be0 100644 (file)
@@ -127,7 +127,7 @@ public:
 public:
     wxSocketState() : wxObject() {}
 
 public:
     wxSocketState() : wxObject() {}
 
-    DECLARE_NO_COPY_CLASS(wxSocketState)
+    wxDECLARE_NO_COPY_CLASS(wxSocketState);
 };
 
 // wxSocketWaitModeChanger: temporarily change the socket flags affecting its
 };
 
 // wxSocketWaitModeChanger: temporarily change the socket flags affecting its
@@ -163,7 +163,7 @@ private:
     wxSocketBase * const m_socket;
     const int m_oldflags;
 
     wxSocketBase * const m_socket;
     const int m_oldflags;
 
-    DECLARE_NO_COPY_CLASS(wxSocketWaitModeChanger)
+    wxDECLARE_NO_COPY_CLASS(wxSocketWaitModeChanger);
 };
 
 // wxSocketRead/WriteGuard are instantiated before starting reading
 };
 
 // wxSocketRead/WriteGuard are instantiated before starting reading
@@ -189,7 +189,7 @@ public:
 private:
     wxSocketBase * const m_socket;
 
 private:
     wxSocketBase * const m_socket;
 
-    DECLARE_NO_COPY_CLASS(wxSocketReadGuard)
+    wxDECLARE_NO_COPY_CLASS(wxSocketReadGuard);
 };
 
 class wxSocketWriteGuard
 };
 
 class wxSocketWriteGuard
@@ -213,7 +213,7 @@ public:
 private:
     wxSocketBase * const m_socket;
 
 private:
     wxSocketBase * const m_socket;
 
-    DECLARE_NO_COPY_CLASS(wxSocketWriteGuard)
+    wxDECLARE_NO_COPY_CLASS(wxSocketWriteGuard);
 };
 
 // ============================================================================
 };
 
 // ============================================================================
@@ -1328,6 +1328,20 @@ wxSocketBase::DoWait(long timeout, wxSocketEventFlags flags)
         eventLoop = NULL;
     }
 
         eventLoop = NULL;
     }
 
+    // Make sure the events we're interested in are enabled before waiting for
+    // them: this is really necessary here as otherwise this could happen:
+    //  1. DoRead(wxSOCKET_WAITALL) is called
+    //  2. There is nothing to read so DoWait(wxSOCKET_INPUT_FLAG) is called
+    //  3. Some, but not all data appears, wxSocketImplUnix::OnReadWaiting()
+    //     is called and wxSOCKET_INPUT_FLAG events are disabled in it
+    //  4. Because of wxSOCKET_WAITALL we call DoWait() again but the events
+    //     are still disabled and we block forever
+    //
+    // More elegant solution would be nice but for now simply re-enabling the
+    // events here will do
+    m_impl->ReenableEvents(flags & (wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG));
+
+
     // Wait until we receive the event we're waiting for or the timeout expires
     // (but note that we always execute the loop at least once, even if timeout
     // is 0 as this is used for polling)
     // Wait until we receive the event we're waiting for or the timeout expires
     // (but note that we always execute the loop at least once, even if timeout
     // is 0 as this is used for polling)