@@ -92,7 +92,9 @@ CRemoteMasterServer::~CRemoteMasterServer()
9292void CRemoteMasterServer::Init (const SString& strURL)
9393{
9494 m_strURL = strURL;
95- GetHTTP ()->SetMaxConnections (5 );
95+ CNetHTTPDownloadManagerInterface* pHTTP = GetHTTP ();
96+ if (pHTTP)
97+ pHTTP->SetMaxConnections (5 );
9698}
9799
98100// /////////////////////////////////////////////////////////////
@@ -120,12 +122,19 @@ void CRemoteMasterServer::Refresh()
120122 if (GetTickCount64_ () - m_llLastRefreshTime < 60000 && m_strStage == " hasdata" )
121123 return ;
122124
125+ CNetHTTPDownloadManagerInterface* pHTTP = GetHTTP ();
126+ if (!pHTTP)
127+ {
128+ m_strStage = " nogood" ;
129+ return ;
130+ }
131+
123132 // Send new request
124133 m_strStage = " waitingreply" ;
125134 m_llLastRefreshTime = GetTickCount64_ ();
126135 SHttpRequestOptions options;
127136 options.uiConnectionAttempts = 1 ;
128- if (GetHTTP () ->QueueFile (m_strURL, NULL , this , &CRemoteMasterServer::StaticDownloadFinished, options))
137+ if (pHTTP ->QueueFile (m_strURL, NULL , this , &CRemoteMasterServer::StaticDownloadFinished, options))
129138 {
130139 m_bPendingDownload = true ;
131140 AddRef (); // Keep alive
@@ -141,7 +150,17 @@ void CRemoteMasterServer::Cancel()
141150 if (!m_bPendingDownload)
142151 return ;
143152
144- if (GetHTTP ()->CancelDownload (this , &CRemoteMasterServer::StaticDownloadFinished))
153+ CNetHTTPDownloadManagerInterface* pHTTP = GetHTTP ();
154+ if (!pHTTP)
155+ {
156+ // HTTP manager destroyed - callback won't be called, so Release() here
157+ m_bPendingDownload = false ;
158+ m_strStage.clear ();
159+ Release ();
160+ return ;
161+ }
162+
163+ if (pHTTP->CancelDownload (this , &CRemoteMasterServer::StaticDownloadFinished))
145164 {
146165 m_bPendingDownload = false ;
147166 m_strStage.clear ();
@@ -200,7 +219,9 @@ void CRemoteMasterServer::DownloadFinished(const SHttpDownloadResult& result)
200219// /////////////////////////////////////////////////////////////
201220bool CRemoteMasterServer::HasData ()
202221{
203- GetHTTP ()->ProcessQueuedFiles ();
222+ CNetHTTPDownloadManagerInterface* pHTTP = GetHTTP ();
223+ if (pHTTP)
224+ pHTTP->ProcessQueuedFiles ();
204225 return m_strStage == " hasdata" ;
205226}
206227
0 commit comments