1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 07:19:42 +01:00

* Fixed crash bug in AudioEngine: timer-events can arrive after we called stop.

This commit is contained in:
Christian Muehlhaeuser 2011-09-09 11:29:22 +02:00
parent a667fbd8b4
commit a65d037def

View File

@ -165,14 +165,17 @@ AudioEngine::stop()
if ( !m_playlist.isNull() )
m_playlist.data()->reset();
setCurrentTrack( Tomahawk::result_ptr() );
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->duration() ) * 100.0 );
emit stopped();
setCurrentTrack( Tomahawk::result_ptr() );
Tomahawk::InfoSystem::InfoTypeMap map;
map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant();
if ( m_waitingOnNewTrack )
{
sendWaitingNotification();
}
else if ( TomahawkSettings::instance()->verboseNotifications() )
{
QVariantMap stopInfo;
@ -193,6 +196,7 @@ AudioEngine::previous()
loadPreviousTrack();
}
void
AudioEngine::next()
{
@ -202,6 +206,7 @@ AudioEngine::next()
loadNextTrack();
}
bool
AudioEngine::canGoNext()
{
@ -229,6 +234,7 @@ AudioEngine::canGoNext()
return m_playlist.data()->hasNextItem();
}
bool
AudioEngine::canGoPrevious()
{
@ -242,6 +248,7 @@ AudioEngine::canGoPrevious()
return true;
}
bool
AudioEngine::canSeek()
{
@ -253,6 +260,7 @@ AudioEngine::canSeek()
return !m_playlist.isNull() && ( m_playlist.data()->seekRestrictions() != PlaylistInterface::NoSeek ) && phononCanSeek;
}
void
AudioEngine::seek( qint64 ms )
{
@ -270,12 +278,14 @@ AudioEngine::seek( qint64 ms )
}
}
void
AudioEngine::seek( int ms )
{
seek( (qint64) ms );
}
void
AudioEngine::setVolume( int percentage )
{
@ -626,22 +636,25 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
void
AudioEngine::timerTriggered( qint64 time )
{
emit timerMilliSeconds( time );
if ( m_timeElapsed != time / 1000 )
{
m_timeElapsed = time / 1000;
emit timerSeconds( m_timeElapsed );
if ( m_currentTrack->duration() == 0 )
if ( !m_currentTrack.isNull() )
{
emit timerPercentage( 0 );
}
else
{
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->duration() ) * 100.0 );
if ( m_currentTrack->duration() == 0 )
{
emit timerPercentage( 0 );
}
else
{
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->duration() ) * 100.0 );
}
}
}
emit timerMilliSeconds( time );
}