mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
UI: Avoid PathBrowser lock with no remote files.
Only needs locks once the thread starts.
This commit is contained in:
parent
04a077e2f5
commit
58f6751891
2 changed files with 14 additions and 6 deletions
|
@ -146,22 +146,22 @@ void PathBrowser::SetPath(const std::string &path) {
|
|||
}
|
||||
|
||||
void PathBrowser::HandlePath() {
|
||||
std::lock_guard<std::mutex> guard(pendingLock_);
|
||||
|
||||
if (!path_.empty() && path_[0] == '!') {
|
||||
if (pendingActive_)
|
||||
ResetPending();
|
||||
ready_ = true;
|
||||
pendingCancel_ = true;
|
||||
pendingPath_.clear();
|
||||
return;
|
||||
}
|
||||
if (!startsWith(path_, "http://") && !startsWith(path_, "https://")) {
|
||||
if (pendingActive_)
|
||||
ResetPending();
|
||||
ready_ = true;
|
||||
pendingCancel_ = true;
|
||||
pendingPath_.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(pendingLock_);
|
||||
ready_ = false;
|
||||
pendingActive_ = true;
|
||||
pendingCancel_ = false;
|
||||
pendingFiles_.clear();
|
||||
pendingPath_ = path_;
|
||||
|
@ -201,6 +201,12 @@ void PathBrowser::HandlePath() {
|
|||
});
|
||||
}
|
||||
|
||||
void PathBrowser::ResetPending() {
|
||||
std::lock_guard<std::mutex> guard(pendingLock_);
|
||||
pendingCancel_ = true;
|
||||
pendingPath_.clear();
|
||||
}
|
||||
|
||||
bool PathBrowser::IsListingReady() {
|
||||
return ready_;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
private:
|
||||
void HandlePath();
|
||||
void ResetPending();
|
||||
|
||||
std::string path_;
|
||||
std::string pendingPath_;
|
||||
|
@ -44,6 +45,7 @@ private:
|
|||
std::condition_variable pendingCond_;
|
||||
std::mutex pendingLock_;
|
||||
std::thread pendingThread_;
|
||||
bool pendingActive_ = false;
|
||||
bool pendingCancel_ = false;
|
||||
bool pendingStop_ = false;
|
||||
bool ready_ = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue