From 497928d6938d61697985be69ef611b746800a012 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Tue, 10 Jul 2012 14:59:35 +0100 Subject: [PATCH] Don't try seeking a song if there's no song playing, or the song isn't seekable. Fixes issue 3041 --- src/core/player.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/player.cpp b/src/core/player.cpp index 50b42739c..1b466fe74 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -345,8 +345,16 @@ void Player::CurrentMetadataChanged(const Song& metadata) { } void Player::SeekTo(int seconds) { - qint64 nanosec = qBound(0ll, qint64(seconds) * kNsecPerSec, - engine_->length_nanosec()); + const qint64 length_nanosec = engine_->length_nanosec(); + + // If the length is 0 then either there is no song playing, or the song isn't + // seekable. + if (length_nanosec == 0) { + return; + } + + const qint64 nanosec = qBound(0ll, qint64(seconds) * kNsecPerSec, + length_nanosec); engine_->Seek(nanosec); // If we seek the track we don't want to submit it to last.fm