summaryrefslogtreecommitdiff
path: root/LotWUsers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LotWUsers.cpp')
-rw-r--r--LotWUsers.cpp14
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;
}