Destroy default wxWebSession in module
This commit is contained in:
@@ -234,6 +234,8 @@ public:
|
||||
|
||||
static wxWebSession& GetDefault();
|
||||
|
||||
static void DestroyDefault();
|
||||
|
||||
static wxWebSession* New(const wxString& backend = wxWebSessionBackendDefault);
|
||||
|
||||
static void RegisterFactory(const wxString& backend, wxSharedPtr<wxWebSessionFactory> factory);
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "wx/webrequest.h"
|
||||
#include "wx/mstream.h"
|
||||
#include "wx/module.h"
|
||||
#include "wx/uri.h"
|
||||
#include "wx/filefn.h"
|
||||
#include "wx/filename.h"
|
||||
@@ -403,6 +404,11 @@ wxWebSession& wxWebSession::GetDefault()
|
||||
return *ms_defaultSession;
|
||||
}
|
||||
|
||||
void wxWebSession::DestroyDefault()
|
||||
{
|
||||
ms_defaultSession.reset();
|
||||
}
|
||||
|
||||
// static
|
||||
wxWebSession* wxWebSession::New(const wxString& backend)
|
||||
{
|
||||
@@ -449,4 +455,31 @@ bool wxWebSession::IsBackendAvailable(const wxString& backend)
|
||||
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
|
||||
|
Reference in New Issue
Block a user