From 8bf668665b107469086f16cb8ad23e47d479d2b4 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:14:37 +0200 Subject: 4.0 --- ui/check_version.cpp | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'ui/check_version.cpp') 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 #include #include #include @@ -14,36 +15,15 @@ #include #include "msg_popup.h" #include "../shared/standard_paths.h" +#include "loki/ScopeGuard.h" #include #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 httpStream(webAccess.GetInputStream(wxT("/viewvc/freefilesync/version/version.txt"))); + //must be deleted BEFORE webAccess is closed if (httpStream && webAccess.GetError() == wxPROTO_NOERR) { -- cgit