mirror of https://github.com/OpenTTD/OpenTTD
(svn r15195) -Fix: don't crash when removing from something you're iterating over
parent
727ffeedc9
commit
4bf2326bd1
|
@ -750,29 +750,37 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
||||||
|
|
||||||
void ClientNetworkContentSocketHandler::OnConnect(bool success)
|
void ClientNetworkContentSocketHandler::OnConnect(bool success)
|
||||||
{
|
{
|
||||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); iter++) {
|
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||||
(*iter)->OnConnect(success);
|
ContentCallback *cb = *iter;
|
||||||
|
cb->OnConnect(success);
|
||||||
|
if (*iter != cb) iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientNetworkContentSocketHandler::OnDisconnect()
|
void ClientNetworkContentSocketHandler::OnDisconnect()
|
||||||
{
|
{
|
||||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); iter++) {
|
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||||
(*iter)->OnDisconnect();
|
ContentCallback *cb = *iter;
|
||||||
|
cb->OnDisconnect();
|
||||||
|
if (*iter != cb) iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientNetworkContentSocketHandler::OnReceiveContentInfo(const ContentInfo *ci)
|
void ClientNetworkContentSocketHandler::OnReceiveContentInfo(const ContentInfo *ci)
|
||||||
{
|
{
|
||||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); iter++) {
|
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||||
(*iter)->OnReceiveContentInfo(ci);
|
ContentCallback *cb = *iter;
|
||||||
|
cb->OnReceiveContentInfo(ci);
|
||||||
|
if (*iter != cb) iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientNetworkContentSocketHandler::OnDownloadProgress(const ContentInfo *ci, uint bytes)
|
void ClientNetworkContentSocketHandler::OnDownloadProgress(const ContentInfo *ci, uint bytes)
|
||||||
{
|
{
|
||||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); iter++) {
|
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||||
(*iter)->OnDownloadProgress(ci, bytes);
|
ContentCallback *cb = *iter;
|
||||||
|
cb->OnDownloadProgress(ci, bytes);
|
||||||
|
if (*iter != cb) iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,8 +791,10 @@ void ClientNetworkContentSocketHandler::OnDownloadComplete(ContentID cid)
|
||||||
ci->state = ContentInfo::ALREADY_HERE;
|
ci->state = ContentInfo::ALREADY_HERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); iter++) {
|
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||||
(*iter)->OnDownloadComplete(cid);
|
ContentCallback *cb = *iter;
|
||||||
|
cb->OnDownloadComplete(cid);
|
||||||
|
if (*iter != cb) iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue