* Fixed some "memory leak"
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1077 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -270,7 +270,6 @@ class WXDLLEXPORT wxSocketHandler : public wxObject
|
|||||||
{
|
{
|
||||||
DECLARE_CLASS(wxSocketHandler)
|
DECLARE_CLASS(wxSocketHandler)
|
||||||
protected:
|
protected:
|
||||||
static wxSocketHandler *master;
|
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
wxList *smsg_list;
|
wxList *smsg_list;
|
||||||
struct wxSockHandlerInternal *internal;
|
struct wxSockHandlerInternal *internal;
|
||||||
@@ -280,6 +279,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
enum SockStatus { SOCK_NONE, SOCK_DATA, SOCK_CONNECT, SOCK_DISCONNECT,
|
enum SockStatus { SOCK_NONE, SOCK_DATA, SOCK_CONNECT, SOCK_DISCONNECT,
|
||||||
SOCK_ERROR };
|
SOCK_ERROR };
|
||||||
|
static wxSocketHandler *master;
|
||||||
|
|
||||||
wxSocketHandler();
|
wxSocketHandler();
|
||||||
virtual ~wxSocketHandler();
|
virtual ~wxSocketHandler();
|
||||||
@@ -303,8 +303,7 @@ public:
|
|||||||
(wxSocketBase::wxSockFlags flags = wxSocketBase::NONE);
|
(wxSocketBase::wxSockFlags flags = wxSocketBase::NONE);
|
||||||
|
|
||||||
// Create or reuse a socket handler
|
// Create or reuse a socket handler
|
||||||
static wxSocketHandler& Master()
|
static wxSocketHandler& Master() { return *master; }
|
||||||
{ return *((master) ? (master) : (master = new wxSocketHandler())); }
|
|
||||||
|
|
||||||
#if defined(WXSOCK_INTERNAL) && defined(__WINDOWS__)
|
#if defined(WXSOCK_INTERNAL) && defined(__WINDOWS__)
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ class WXDLLEXPORT wxURL : public wxObject {
|
|||||||
DECLARE_DYNAMIC_CLASS(wxURL)
|
DECLARE_DYNAMIC_CLASS(wxURL)
|
||||||
protected:
|
protected:
|
||||||
static wxProtoInfo *g_protocols;
|
static wxProtoInfo *g_protocols;
|
||||||
static wxHTTP g_proxy;
|
static wxHTTP *g_proxy;
|
||||||
wxProtoInfo *m_protoinfo;
|
wxProtoInfo *m_protoinfo;
|
||||||
wxProtocol *m_protocol;
|
wxProtocol *m_protocol;
|
||||||
wxHTTP m_proxy;
|
wxHTTP m_proxy;
|
||||||
@@ -52,6 +52,7 @@ protected:
|
|||||||
bool FetchProtocol();
|
bool FetchProtocol();
|
||||||
|
|
||||||
friend class wxProtoInfo;
|
friend class wxProtoInfo;
|
||||||
|
friend class wxProtocolModule;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
wxURL(const wxString& url);
|
wxURL(const wxString& url);
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "wx/protocol/protocol.h"
|
#include "wx/protocol/protocol.h"
|
||||||
#include "wx/url.h"
|
#include "wx/url.h"
|
||||||
|
#include "wx/module.h"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// wxProtoInfo
|
// wxProtoInfo
|
||||||
@@ -108,3 +109,31 @@ wxProtocolError GetLine(wxSocketBase *sock, wxString& result) {
|
|||||||
return wxPROTO_NOERR;
|
return wxPROTO_NOERR;
|
||||||
#undef PROTO_BSIZE
|
#undef PROTO_BSIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Module
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxProtocolModule: public wxModule {
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxProtocolModule)
|
||||||
|
public:
|
||||||
|
wxProtocolModule() {}
|
||||||
|
bool OnInit();
|
||||||
|
void OnExit();
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !USE_SHARED_LIBRARY
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxProtocolModule, wxModule)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool wxProtocolModule::OnInit()
|
||||||
|
{
|
||||||
|
wxURL::g_proxy = new wxHTTP();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxProtocolModule::OnExit()
|
||||||
|
{
|
||||||
|
delete wxURL::g_proxy;
|
||||||
|
wxURL::g_proxy = NULL;
|
||||||
|
}
|
||||||
|
@@ -89,6 +89,7 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// wxSocket headers
|
// wxSocket headers
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include "wx/module.h"
|
||||||
#define WXSOCK_INTERNAL
|
#define WXSOCK_INTERNAL
|
||||||
#include "wx/sckaddr.h"
|
#include "wx/sckaddr.h"
|
||||||
#include "wx/socket.h"
|
#include "wx/socket.h"
|
||||||
@@ -153,6 +154,17 @@ int PASCAL FAR __WSAFDIsSet(SOCKET fd, fd_set FAR *set)
|
|||||||
// Some patch ///// END
|
// Some patch ///// END
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Module
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
class wxSocketModule: public wxModule {
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxSocketModule)
|
||||||
|
public:
|
||||||
|
wxSocketModule() {}
|
||||||
|
bool OnInit();
|
||||||
|
void OnExit();
|
||||||
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// ClassInfos
|
// ClassInfos
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
@@ -162,6 +174,7 @@ IMPLEMENT_CLASS(wxSocketServer, wxSocketBase)
|
|||||||
IMPLEMENT_CLASS(wxSocketClient, wxSocketBase)
|
IMPLEMENT_CLASS(wxSocketClient, wxSocketBase)
|
||||||
IMPLEMENT_CLASS(wxSocketHandler, wxObject)
|
IMPLEMENT_CLASS(wxSocketHandler, wxObject)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent)
|
IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class wxSockWakeUp : public wxTimer {
|
class wxSockWakeUp : public wxTimer {
|
||||||
@@ -1543,5 +1556,15 @@ HWND wxSocketHandler::GetHWND() const
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool wxSocketModule::OnInit() {
|
||||||
|
wxSocketHandler::master = new wxSocketHandler();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxSocketModule::OnExit() {
|
||||||
|
delete wxSocketHandler::master;
|
||||||
|
wxSocketHandler::master = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// __WXSTUBS__
|
// __WXSTUBS__
|
||||||
|
@@ -41,7 +41,7 @@ IMPLEMENT_CLASS(wxURL, wxObject)
|
|||||||
|
|
||||||
// Protocols list
|
// Protocols list
|
||||||
wxProtoInfo *wxURL::g_protocols = NULL;
|
wxProtoInfo *wxURL::g_protocols = NULL;
|
||||||
wxHTTP wxURL::g_proxy;
|
wxHTTP *wxURL::g_proxy;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// wxURL ////////////////////////////////////////////////////////
|
// wxURL ////////////////////////////////////////////////////////
|
||||||
@@ -56,8 +56,8 @@ wxHTTP wxURL::g_proxy;
|
|||||||
wxURL::wxURL(const wxString& url)
|
wxURL::wxURL(const wxString& url)
|
||||||
{
|
{
|
||||||
m_protocol = NULL;
|
m_protocol = NULL;
|
||||||
if (g_proxy.IsConnected()) {
|
if (g_proxy->IsConnected()) {
|
||||||
m_protocol = &g_proxy;
|
m_protocol = g_proxy;
|
||||||
m_protoname = "proxy";
|
m_protoname = "proxy";
|
||||||
m_path = url;
|
m_path = url;
|
||||||
return;
|
return;
|
||||||
@@ -267,7 +267,7 @@ wxInputStream *wxURL::GetInputStream(void)
|
|||||||
|
|
||||||
void wxURL::SetDefaultProxy(const wxString& url_proxy)
|
void wxURL::SetDefaultProxy(const wxString& url_proxy)
|
||||||
{
|
{
|
||||||
g_proxy.Close();
|
g_proxy->Close();
|
||||||
|
|
||||||
if (url_proxy.IsNull())
|
if (url_proxy.IsNull())
|
||||||
return;
|
return;
|
||||||
@@ -281,7 +281,7 @@ void wxURL::SetDefaultProxy(const wxString& url_proxy)
|
|||||||
addr.Hostname(hostname);
|
addr.Hostname(hostname);
|
||||||
addr.Service(port);
|
addr.Service(port);
|
||||||
|
|
||||||
g_proxy.Connect(addr);
|
g_proxy->Connect(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxURL::SetProxy(const wxString& url_proxy)
|
void wxURL::SetProxy(const wxString& url_proxy)
|
||||||
|
Reference in New Issue
Block a user