mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-30 17:02:19 +00:00
UI: Join downloads on destruct.
This commit is contained in:
parent
1307273dd7
commit
987448577f
@ -428,16 +428,16 @@ int Client::ReadResponseEntity(Buffer *readbuf, const std::vector<std::string> &
|
||||
}
|
||||
|
||||
Download::Download(const std::string &url, const std::string &outfile)
|
||||
: progress_(0.0f), url_(url), outfile_(outfile), resultCode_(0), completed_(false), failed_(false), cancelled_(false), hidden_(false) {
|
||||
: url_(url), outfile_(outfile) {
|
||||
}
|
||||
|
||||
Download::~Download() {
|
||||
|
||||
if (thread_.joinable())
|
||||
thread_.join();
|
||||
}
|
||||
|
||||
void Download::Start(std::shared_ptr<Download> self) {
|
||||
std::thread th(std::bind(&Download::Do, this, self));
|
||||
th.detach();
|
||||
thread_ = std::thread(std::bind(&Download::Do, this, self));
|
||||
}
|
||||
|
||||
void Download::SetFailed(int code) {
|
||||
@ -577,6 +577,7 @@ void Downloader::CancelAll() {
|
||||
for (size_t i = 0; i < downloads_.size(); i++) {
|
||||
downloads_[i]->Cancel();
|
||||
}
|
||||
downloads_.clear();
|
||||
}
|
||||
|
||||
} // http
|
||||
|
@ -142,16 +142,17 @@ private:
|
||||
int PerformGET(const std::string &url);
|
||||
std::string RedirectLocation(const std::string &baseUrl);
|
||||
void SetFailed(int code);
|
||||
float progress_;
|
||||
float progress_ = 0.0f;
|
||||
Buffer buffer_;
|
||||
std::vector<std::string> responseHeaders_;
|
||||
std::string url_;
|
||||
std::string outfile_;
|
||||
int resultCode_;
|
||||
bool completed_;
|
||||
bool failed_;
|
||||
bool cancelled_;
|
||||
bool hidden_;
|
||||
std::thread thread_;
|
||||
int resultCode_ = 0;
|
||||
bool completed_ = false;
|
||||
bool failed_ = false;
|
||||
bool cancelled_ = false;
|
||||
bool hidden_ = false;
|
||||
std::function<void(Download &)> callback_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user