Skip to content

Commit 3d3d00e

Browse files
Synchronize changes from 1.6 master branch [ci skip]
f5aa603 Addendum #2 to 5429339 (Server list crash fixes) 13b8473 Update client en_US pot
2 parents a1c5701 + f5aa603 commit 3d3d00e

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

Client/core/ServerBrowser/CServerBrowser.RemoteMasterServer.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ CRemoteMasterServer::~CRemoteMasterServer()
9292
void 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
///////////////////////////////////////////////////////////////
201220
bool CRemoteMasterServer::HasData()
202221
{
203-
GetHTTP()->ProcessQueuedFiles();
222+
CNetHTTPDownloadManagerInterface* pHTTP = GetHTTP();
223+
if (pHTTP)
224+
pHTTP->ProcessQueuedFiles();
204225
return m_strStage == "hasdata";
205226
}
206227

Client/core/ServerBrowser/CServerBrowser.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ CServerBrowser::CServerBrowser()
374374

375375
CServerBrowser::~CServerBrowser()
376376
{
377+
// Suspend all server list activity and cancel pending network operations FIRST
378+
// This must be done before DeleteTab() destroys the server lists, and while
379+
// the network subsystem is still available (it may be destroyed before this destructor)
380+
SuspendServerLists();
381+
377382
// Save options now and disable selection handler
378383
SaveOptions(true);
379384
if (m_pPanel)
@@ -992,6 +997,13 @@ void CServerBrowser::StartRefresh(ServerBrowserType type)
992997

993998
m_iSelectedServer[index] = -1;
994999
m_bPendingRefresh[index] = false;
1000+
1001+
// Cancel any in-progress batch refresh to prevent iterator invalidation
1002+
// when pList->Refresh() calls Clear() on the server list
1003+
m_ListRefreshState[index].bActive = false;
1004+
m_ListRefreshState[index].pList = nullptr;
1005+
m_ListRefreshState[index].filterSnapshot.reset();
1006+
9951007
pList->Refresh();
9961008
m_bInitialRefreshDone[index] = true;
9971009
}

0 commit comments

Comments
 (0)