diff options
author | Luciana Fujii Pontello <luciana@fujii.eti.br> | 2013-04-16 00:35:44 -0300 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2013-06-05 12:00:49 +0300 |
commit | 7282e200869d99d5d3f21778f7d89d2af1bb1590 (patch) | |
tree | 0f57b6de272bc6c7172f5086c8d17f8e92c2f586 | |
parent | 1ac15da8b248f7f0ca5d88c0004590b30e0ef4b2 (diff) |
qt5: examples: Fix floating point exception in player
QTime() in QT5 is different than QTime(0,0). The first won't produce a
valid date, and can't be used in QTime.msecsTo and other methods that
rely on a valid QTime, otherwise 0 will be returned.
-rw-r--r-- | examples/player/mediaapp.cpp | 6 | ||||
-rw-r--r-- | examples/player/player.cpp | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/examples/player/mediaapp.cpp b/examples/player/mediaapp.cpp index ab07fff..0285bae 100644 --- a/examples/player/mediaapp.cpp +++ b/examples/player/mediaapp.cpp @@ -137,7 +137,7 @@ void MediaApp::onPositionChanged() length.toString("hh:mm:ss.zzz")); if (length != QTime(0,0)) { - m_positionSlider->setValue(curpos.msecsTo(QTime()) * 1000 / length.msecsTo(QTime())); + m_positionSlider->setValue(curpos.msecsTo(QTime(0,0)) * 1000 / length.msecsTo(QTime(0,0))); } else { m_positionSlider->setValue(0); } @@ -151,9 +151,9 @@ void MediaApp::onPositionChanged() /* Called when the user changes the slider's position */ void MediaApp::setPosition(int value) { - uint length = -m_player->length().msecsTo(QTime()); + uint length = -m_player->length().msecsTo(QTime(0,0)); if (length != 0 && value > 0) { - QTime pos; + QTime pos(0,0); pos = pos.addMSecs(length * (value / 1000.0)); m_player->setPosition(pos); } diff --git a/examples/player/player.cpp b/examples/player/player.cpp index 6d7fd4f..bfcd091 100644 --- a/examples/player/player.cpp +++ b/examples/player/player.cpp @@ -84,7 +84,7 @@ QTime Player::position() const m_pipeline->query(query); return QGst::ClockTime(query->position()).toTime(); } else { - return QTime(); + return QTime(0,0); } } @@ -135,7 +135,7 @@ QTime Player::length() const m_pipeline->query(query); return QGst::ClockTime(query->duration()).toTime(); } else { - return QTime(); + return QTime(0,0); } } |