diff options
| author | Christoph Berg <christoph.berg@credativ.de> | 2019-03-11 14:19:23 +0100 |
|---|---|---|
| committer | Christoph Berg <christoph.berg@credativ.de> | 2019-03-11 14:19:23 +0100 |
| commit | 200de07a95209a55d6019ba87f0abc78d302bf4c (patch) | |
| tree | 3b2922eb5d89b01ad214cae492e871c3bfb5df18 /LotWUsers.cpp | |
| parent | e0737c56c1e384e05064a0c6e1ac46979371041b (diff) | |
New upstream version 2.0.1+repackupstream/2.0.1+repack
Diffstat (limited to 'LotWUsers.cpp')
| -rw-r--r-- | LotWUsers.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/LotWUsers.cpp b/LotWUsers.cpp index 3876cd7b..877e7054 100644 --- a/LotWUsers.cpp +++ b/LotWUsers.cpp @@ -1,6 +1,7 @@ #include "LotWUsers.hpp" #include <future> +#include <chrono> #include <QHash> #include <QString> @@ -265,7 +266,9 @@ void LotWUsers::set_age_constraint (qint64 uploaded_since_days) bool LotWUsers::user (QString const& call) const { - if (m_->future_load_.valid ()) + // check if a pending asynchronous load is ready + if (m_->future_load_.valid () + && std::future_status::ready == m_->future_load_.wait_for (std::chrono::seconds {0})) { try { @@ -278,10 +281,13 @@ bool LotWUsers::user (QString const& call) const } Q_EMIT load_finished (); } - auto p = m_->last_uploaded_.constFind (call); - if (p != m_->last_uploaded_.end ()) + if (m_->last_uploaded_.size ()) { - return p.value ().daysTo (QDate::currentDate ()) <= m_->age_constraint_; + auto p = m_->last_uploaded_.constFind (call); + if (p != m_->last_uploaded_.end ()) + { + return p.value ().daysTo (QDate::currentDate ()) <= m_->age_constraint_; + } } return false; } |
