Avoid crash when start time can not be parsed
This commit is contained in:
parent
31ad8b979c
commit
a5f629d710
|
@ -753,7 +753,7 @@ inline CppUtilities::DateTime SyncthingConnection::startTime() const
|
|||
*/
|
||||
inline CppUtilities::TimeSpan SyncthingConnection::uptime() const
|
||||
{
|
||||
return CppUtilities::DateTime::gmtNow() - m_startTime;
|
||||
return m_startTime.isNull() ? CppUtilities::TimeSpan() : CppUtilities::DateTime::gmtNow() - m_startTime;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -678,7 +678,11 @@ void SyncthingConnection::readStatus()
|
|||
|
||||
const auto replyObj(replyDoc.object());
|
||||
emitMyIdChanged(replyObj.value(QLatin1String("myID")).toString());
|
||||
m_startTime = DateTime::fromIsoStringGmt(replyObj.value(QLatin1String("startTime")).toString().toLocal8Bit().data());
|
||||
try {
|
||||
m_startTime = DateTime::fromIsoStringGmt(replyObj.value(QLatin1String("startTime")).toString().toLocal8Bit().data());
|
||||
} catch (const ConversionException &) {
|
||||
m_startTime = DateTime(); // tracking the start time isn't very important so just ignore
|
||||
}
|
||||
m_hasStatus = true;
|
||||
|
||||
if (m_keepPolling) {
|
||||
|
|
Loading…
Reference in New Issue