diff --git a/include/wx/private/socket.h b/include/wx/private/socket.h index 674edfaa82..d953f082ec 100644 --- a/include/wx/private/socket.h +++ b/include/wx/private/socket.h @@ -267,9 +267,6 @@ public: // named) OnRequest() method void NotifyOnStateChange(wxSocketNotify event); - // FIXME: this one probably isn't needed here at all - virtual void Notify(bool WXUNUSED(notify)) { } - // TODO: make these fields protected and provide accessors for those of // them that wxSocketBase really needs //protected: diff --git a/include/wx/unix/private/sockunix.h b/include/wx/unix/private/sockunix.h index 14bc5e5a1c..a104888488 100644 --- a/include/wx/unix/private/sockunix.h +++ b/include/wx/unix/private/sockunix.h @@ -26,7 +26,6 @@ public: m_fds[0] = m_fds[1] = -1; - m_use_events = false; m_enabledCallbacks = 0; } @@ -35,8 +34,6 @@ public: int Read(void *buffer, int size); int Write(const void *buffer, int size); - //attach or detach from main loop - void Notify(bool flag); // wxFDIOHandler methods virtual void OnReadWaiting(); @@ -73,27 +70,16 @@ private: EnableEvents(); } - // enable or disable notifications for socket input/output events but only - // if m_use_events is true; do nothing otherwise - virtual void EnableEvents() - { - if ( m_use_events ) - DoEnableEvents(true); + // enable or disable notifications for socket input/output events + void EnableEvents() { DoEnableEvents(true); } + void DisableEvents() { DoEnableEvents(false); } - void DisableEvents() - { - if ( m_use_events ) - DoEnableEvents(false); - } - - // really enable or disable socket input/output events, regardless of - // m_use_events value + // really enable or disable socket input/output events void DoEnableEvents(bool enable); - // enable or disable events for the given event if m_use_events; do nothing - // otherwise + // enable or disable events for the given event // // notice that these functions also update m_detected: EnableEvent() clears // the corresponding bit in it and DisableEvent() sets it @@ -107,9 +93,6 @@ private: protected: - // true if socket should fire events - bool m_use_events; - // descriptors for input and output event notification channels associated // with the socket int m_fds[2]; diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 2c91654040..221af68ee4 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -667,7 +667,7 @@ bool wxSocketBase::Destroy() // Shutdown and close the socket Close(); - // Supress events from now on + // Suppress events from now on Notify(false); // schedule this object for deletion @@ -1540,8 +1540,6 @@ void wxSocketBase::OnRequest(wxSocketNotify notification) void wxSocketBase::Notify(bool notify) { m_notify = notify; - if (m_impl) - m_impl->Notify(notify); } void wxSocketBase::SetNotify(wxSocketEventFlags flags) @@ -1632,7 +1630,6 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr_man, } // Setup the socket as server - m_impl->Notify(m_notify); m_impl->SetLocal(addr_man.GetAddress()); if (GetFlags() & wxSOCKET_REUSEADDR) { @@ -1818,9 +1815,6 @@ bool wxSocketClient::DoConnect(const wxSockAddress& addr_man, m_impl->SetPeer(addr_man.GetAddress()); const wxSocketError err = m_impl->CreateClient(); - //this will register for callbacks - must be called after m_impl->m_fd was initialized - m_impl->Notify(m_notify); - if (err != wxSOCKET_NOERROR) { if (err == wxSOCKET_WOULDBLOCK) @@ -1879,7 +1873,6 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr, if (!m_impl) return; - m_impl->Notify(m_notify); // Setup the socket as non connection oriented m_impl->SetLocal(addr.GetAddress()); if (flags & wxSOCKET_REUSEADDR) diff --git a/src/unix/sockunix.cpp b/src/unix/sockunix.cpp index c56accdc7a..bfe81ba066 100644 --- a/src/unix/sockunix.cpp +++ b/src/unix/sockunix.cpp @@ -535,20 +535,10 @@ wxSocketImpl *wxSocketImplUnix::WaitConnection(wxSocketBase& wxsocket) #else ioctl(connection->m_fd, FIONBIO, &arg); #endif - if (m_use_events) - connection->Notify(true); return connection; } -void wxSocketImplUnix::Notify(bool flag) -{ - if (flag == m_use_events) - return; - m_use_events = flag; - DoEnableEvents(flag); -} - void wxSocketImplUnix::DoEnableEvents(bool flag) { wxSocketManager * const manager = wxSocketManager::Get(); @@ -672,12 +662,9 @@ int wxSocketImplUnix::Read(void *buffer, int size) if ((ret == 0) && m_stream) { /* Make sure wxSOCKET_LOST event gets sent and shut down the socket */ - if (m_use_events) - { - m_detected = wxSOCKET_LOST_FLAG; - OnReadWaiting(); - return 0; - } + m_detected = wxSOCKET_LOST_FLAG; + OnReadWaiting(); + return 0; } else if (ret == -1) { @@ -754,20 +741,14 @@ int wxSocketImplUnix::Write(const void *buffer, int size) void wxSocketImplUnix::EnableEvent(wxSocketNotify event) { - if (m_use_events) - { - m_detected &= ~(1 << event); - wxSocketManager::Get()->Install_Callback(this, event); - } + m_detected &= ~(1 << event); + wxSocketManager::Get()->Install_Callback(this, event); } void wxSocketImplUnix::DisableEvent(wxSocketNotify event) { - if (m_use_events) - { - m_detected |= (1 << event); - wxSocketManager::Get()->Uninstall_Callback(this, event); - } + m_detected |= (1 << event); + wxSocketManager::Get()->Uninstall_Callback(this, event); } int wxSocketImplUnix::Recv_Stream(void *buffer, int size)