mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 07:03:33 +02:00
Store: Fix race condition causing crashes if looking at another game before an icon finishes downloading
This commit is contained in:
+8
-5
@@ -63,25 +63,28 @@ public:
|
||||
|
||||
if (useIconCache && g_iconCache.MarkPending(path_)) {
|
||||
const char *acceptMime = "image/png, image/jpeg, image/*; q=0.9, */*; q=0.8";
|
||||
requestManager_->StartDownloadWithCallback(path_, Path(), http::ProgressBarMode::DELAYED, [&](http::Request &download) {
|
||||
requestManager_->StartDownloadWithCallback(path_, Path(), http::ProgressBarMode::DELAYED, [](http::Request &download) {
|
||||
// Can't touch 'this' in this function! Don't use captures!
|
||||
std::string path = download.url();
|
||||
if (download.ResultCode() == 200) {
|
||||
std::string data;
|
||||
download.buffer().TakeAll(&data);
|
||||
if (!data.empty()) {
|
||||
g_iconCache.InsertIcon(path_, IconFormat::PNG, std::move(data));
|
||||
g_iconCache.InsertIcon(path, IconFormat::PNG, std::move(data));
|
||||
} else {
|
||||
g_iconCache.Cancel(path_);
|
||||
g_iconCache.CancelPending(path);
|
||||
}
|
||||
} else {
|
||||
g_iconCache.Cancel(path_);
|
||||
g_iconCache.CancelPending(path);
|
||||
}
|
||||
}, acceptMime);
|
||||
}
|
||||
}
|
||||
|
||||
~HttpImageFileView() {
|
||||
if (download_)
|
||||
if (download_) {
|
||||
download_->Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
|
||||
Reference in New Issue
Block a user