From d3b93a48b33525bd66c40866009375a619b0006b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 12 Jan 2021 02:16:14 +0100 Subject: [PATCH] Remove wxWebSessionBackendDefault and just use empty string There doesn't seem to be any reason to have this constant, so don't define it and just interpret empty value of backend as meaning to choose the default one in wxWebSession::New(). --- include/wx/webrequest.h | 3 +-- src/common/webrequest.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/wx/webrequest.h b/include/wx/webrequest.h index 68b785b9e9..2f9ffb51e1 100644 --- a/include/wx/webrequest.h +++ b/include/wx/webrequest.h @@ -193,7 +193,6 @@ private: wxWebRequestImplPtr m_impl; }; -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendCURL[]; @@ -213,7 +212,7 @@ public: // factory functions to get access to them. static wxWebSession& GetDefault(); - static wxWebSession New(const wxString& backend = wxWebSessionBackendDefault); + static wxWebSession New(const wxString& backend = wxString()); // Can be used to check if the given backend is available without actually // creating a session using it. diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index eb3ce57102..d5380b48be 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -43,14 +43,6 @@ extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[] = "wxWebSes extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[] = "wxWebSessionBackendURLSession"; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendCURL[] = "wxWebSessionBackendCURL"; -#if wxUSE_WEBREQUEST_WINHTTP -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendWinHTTP"; -#elif wxUSE_WEBREQUEST_URLSESSION -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendURLSession"; -#elif wxUSE_WEBREQUEST_CURL -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendCURL"; -#endif - wxDEFINE_EVENT(wxEVT_WEBREQUEST_STATE, wxWebRequestEvent); wxDEFINE_EVENT(wxEVT_WEBREQUEST_DATA, wxWebRequestEvent); @@ -824,11 +816,23 @@ wxWebSession& wxWebSession::GetDefault() } // static -wxWebSession wxWebSession::New(const wxString& backend) +wxWebSession wxWebSession::New(const wxString& backendOrig) { if ( gs_factoryMap.empty() ) InitFactoryMap(); + wxString backend = backendOrig; + if ( backend.empty() ) + { +#if wxUSE_WEBREQUEST_WINHTTP + backend = wxWebSessionBackendWinHTTP; +#elif wxUSE_WEBREQUEST_URLSESSION + backend = wxWebSessionBackendURLSession; +#elif wxUSE_WEBREQUEST_CURL + backend = wxWebSessionBackendCURL; +#endif + } + wxStringWebSessionFactoryMap::iterator factory = gs_factoryMap.find(backend); wxWebSessionImplPtr impl;