diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 7bd70e2063..26dce5e338 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -146,22 +146,22 @@ void PathBrowser::SetPath(const std::string &path) { } void PathBrowser::HandlePath() { - std::lock_guard 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 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 guard(pendingLock_); + pendingCancel_ = true; + pendingPath_.clear(); +} + bool PathBrowser::IsListingReady() { return ready_; } diff --git a/Common/File/PathBrowser.h b/Common/File/PathBrowser.h index 83e5e2f900..0873b2f58b 100644 --- a/Common/File/PathBrowser.h +++ b/Common/File/PathBrowser.h @@ -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;