diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
commit | 8bf668665b107469086f16cb8ad23e47d479d2b4 (patch) | |
tree | 66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /ui/check_version.cpp | |
parent | 3.21 (diff) | |
download | FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2 FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip |
4.0
Diffstat (limited to 'ui/check_version.cpp')
-rw-r--r-- | ui/check_version.cpp | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/ui/check_version.cpp b/ui/check_version.cpp index 491cf3c2..16eb7719 100644 --- a/ui/check_version.cpp +++ b/ui/check_version.cpp @@ -5,6 +5,7 @@ // ************************************************************************** #include "check_version.h" +#include <memory> #include <wx/msgdlg.h> #include <wx/protocol/http.h> #include <wx/sstream.h> @@ -14,36 +15,15 @@ #include <string_tools.h> #include "msg_popup.h" #include "../shared/standard_paths.h" +#include "loki/ScopeGuard.h" #include <wx/tokenzr.h> #include "../shared/i18n.h" -class CloseConnectionOnExit -{ -public: - CloseConnectionOnExit(wxInputStream* httpStream, wxHTTP& webAccess) : - m_httpStream(httpStream), - m_webAccess(webAccess) {} - - ~CloseConnectionOnExit() - { - delete m_httpStream; //must be deleted BEFORE webAccess is closed - m_webAccess.Close(); - } - -private: - wxInputStream* m_httpStream; - wxHTTP& m_webAccess; -}; - - bool getOnlineVersion(wxString& version) { - wxHTTP webAccess; - wxInputStream* httpStream = NULL; - wxWindowDisabler dummy; - CloseConnectionOnExit dummy2(httpStream, webAccess); + wxHTTP webAccess; webAccess.SetHeader(wxT("Content-type"), wxT("text/html; charset=utf-8")); webAccess.SetTimeout(5); //5 seconds of timeout instead of 10 minutes... @@ -51,7 +31,8 @@ bool getOnlineVersion(wxString& version) { //wxApp::IsMainLoopRunning(); // should return true - httpStream = webAccess.GetInputStream(wxT("/viewvc/freefilesync/version/version.txt")); + std::unique_ptr<wxInputStream> httpStream(webAccess.GetInputStream(wxT("/viewvc/freefilesync/version/version.txt"))); + //must be deleted BEFORE webAccess is closed if (httpStream && webAccess.GetError() == wxPROTO_NOERR) { |