From 6bc30968c596423865a80af7d14301b80aaa954f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Nov 2019 16:00:22 +0100 Subject: [PATCH] Don't create CFSocket unnecessarily when closing wxSocket DoClose() shouldn't do anything if CFSocket hadn't been created at all (as will be the case for blocking sockets) instead of creating it only to destroy it immediately afterwards. --- src/osx/core/sockosx.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/osx/core/sockosx.cpp b/src/osx/core/sockosx.cpp index 899dce6234..f6301c28ca 100644 --- a/src/osx/core/sockosx.cpp +++ b/src/osx/core/sockosx.cpp @@ -63,6 +63,12 @@ public: private: virtual void DoClose() wxOVERRIDE { + // No need to do anything if we had never created the underlying + // socket: this avoids creating it from Uninstall_Callback() completely + // unnecessarily. + if ( !m_socket ) + return; + wxSocketManager * const manager = wxSocketManager::Get(); if ( manager ) {