Destroy default wxWebSession in module
This commit is contained in:
@@ -234,6 +234,8 @@ public:
|
|||||||
|
|
||||||
static wxWebSession& GetDefault();
|
static wxWebSession& GetDefault();
|
||||||
|
|
||||||
|
static void DestroyDefault();
|
||||||
|
|
||||||
static wxWebSession* New(const wxString& backend = wxWebSessionBackendDefault);
|
static wxWebSession* New(const wxString& backend = wxWebSessionBackendDefault);
|
||||||
|
|
||||||
static void RegisterFactory(const wxString& backend, wxSharedPtr<wxWebSessionFactory> factory);
|
static void RegisterFactory(const wxString& backend, wxSharedPtr<wxWebSessionFactory> factory);
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "wx/webrequest.h"
|
#include "wx/webrequest.h"
|
||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
|
#include "wx/module.h"
|
||||||
#include "wx/uri.h"
|
#include "wx/uri.h"
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
@@ -401,6 +402,11 @@ wxWebSession& wxWebSession::GetDefault()
|
|||||||
ms_defaultSession.reset(wxWebSession::New());
|
ms_defaultSession.reset(wxWebSession::New());
|
||||||
|
|
||||||
return *ms_defaultSession;
|
return *ms_defaultSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWebSession::DestroyDefault()
|
||||||
|
{
|
||||||
|
ms_defaultSession.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@@ -449,4 +455,31 @@ bool wxWebSession::IsBackendAvailable(const wxString& backend)
|
|||||||
return factory != ms_factoryMap.end();
|
return factory != ms_factoryMap.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Module ensuring all global/singleton objects are destroyed on shutdown.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WebRequestModule : public wxModule
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebRequestModule()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool OnInit() wxOVERRIDE
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnExit() wxOVERRIDE
|
||||||
|
{
|
||||||
|
wxWebSession::DestroyDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDECLARE_DYNAMIC_CLASS(WebRequestModule);
|
||||||
|
};
|
||||||
|
|
||||||
|
wxIMPLEMENT_DYNAMIC_CLASS(WebRequestModule, wxModule);
|
||||||
|
|
||||||
#endif // wxUSE_WEBREQUEST
|
#endif // wxUSE_WEBREQUEST
|
||||||
|
Reference in New Issue
Block a user