Draw: Atomically release objects.

There may be scenarios where we release objects from separate threads,
just make them safe.
This commit is contained in:
Unknown W. Brackets
2021-10-07 18:22:23 -07:00
parent 309dcb2952
commit abc9ce671a
3 changed files with 15 additions and 21 deletions
+4 -3
View File
@@ -597,9 +597,10 @@ std::shared_ptr<Download> Downloader::StartDownloadWithCallback(
void Downloader::Update() {
restart:
for (size_t i = 0; i < downloads_.size(); i++) {
if (downloads_[i]->Progress() == 1.0f || downloads_[i]->Failed()) {
downloads_[i]->RunCallback();
downloads_[i]->Join();
auto &dl = downloads_[i];
if (dl->Done()) {
dl->RunCallback();
dl->Join();
downloads_.erase(downloads_.begin() + i);
goto restart;
}