From 1c647ec2fcf3e8ce7b576d489a0486e536ea425f Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Mon, 31 Dec 2018 18:10:32 -0500 Subject: [PATCH] video: catch out of range exception when setting time Change-Id: I4540324904ddd152d40169d47a7a5e3cddf0d358 --- videooverlay.cpp | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/videooverlay.cpp b/videooverlay.cpp index 12bcfd0..97a6e82 100644 --- a/videooverlay.cpp +++ b/videooverlay.cpp @@ -88,32 +88,33 @@ void VideoOverlay::setTime() { if (callId.empty()) { return; } - - auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId); - if(callInfo.status == lrc::api::call::Status::IN_PROGRESS) { - - int numSeconds = std::chrono::duration_cast<std::chrono::seconds>( - std::chrono::steady_clock::now() - callInfo.startTime).count(); - - QString labelSec; - QString labelMin; - - int numMinutes = numSeconds / 60; - int remainder = numSeconds - numMinutes * 60; - if (remainder < 10) { - labelSec = ":0" + QString::number(remainder); - } else { - labelSec = ":" + QString::number(remainder); + try { + auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId); + if (callInfo.status == lrc::api::call::Status::IN_PROGRESS) { + + int numSeconds = std::chrono::duration_cast<std::chrono::seconds>( + std::chrono::steady_clock::now() - callInfo.startTime).count(); + + QString labelSec; + QString labelMin; + + int numMinutes = numSeconds / 60; + int remainder = numSeconds - numMinutes * 60; + if (remainder < 10) { + labelSec = ":0" + QString::number(remainder); + } else { + labelSec = ":" + QString::number(remainder); + } + + if (numMinutes < 10) { + labelMin = "0" + QString::number(numMinutes); + } else { + labelMin = QString::number(numMinutes); + } + + ui->timerLabel->setText(labelMin + labelSec); } - - if (numMinutes < 10) { - labelMin = "0" + QString::number(numMinutes); - } else { - labelMin = QString::number(numMinutes); - } - - ui->timerLabel->setText(labelMin + labelSec); - } + } catch (...) { } } void VideoOverlay::toggleContextButtons(bool visible) -- GitLab