diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp index 16202a767..2b74dc156 100644 --- a/src/sourcetree/sourcetreeview.cpp +++ b/src/sourcetree/sourcetreeview.cpp @@ -372,13 +372,31 @@ SourceTreeView::latchOn() void SourceTreeView::playlistChanged( PlaylistInterface* newInterface ) { + const PlaylistInterface* pi = AudioEngine::instance()->playlist(); + bool listeningAlong = false; + source_ptr newSource; + + if ( pi && dynamic_cast< const SourcePlaylistInterface* >( pi ) ) + { + const SourcePlaylistInterface* sourcepi = dynamic_cast< const SourcePlaylistInterface* >( pi ); + if ( !AudioEngine::instance()->state() == AudioEngine::Stopped ) + { + listeningAlong = true; + newSource = sourcepi->source(); + } + } + // If we were latched on and changed, send the listening along stop if ( !m_latch.isNull() ) { - SourcePlaylistInterface* sourcepi = dynamic_cast< SourcePlaylistInterface* >( m_latch.data() ); - Q_ASSERT( sourcepi ); + SourcePlaylistInterface* origsourcepi = dynamic_cast< SourcePlaylistInterface* >( m_latch.data() ); + Q_ASSERT( origsourcepi ); + const source_ptr source = origsourcepi->source(); + + // if we're currently listening along to the same source, no change + if ( listeningAlong && ( !origsourcepi->source().isNull() && origsourcepi->source()->id() == newSource->id() ) ) + return; - const source_ptr source = sourcepi->source(); DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction(); cmd->setSource( SourceList::instance()->getLocal() ); cmd->setAction( "latchOff"); diff --git a/src/sourcetree/sourcetreeview.h b/src/sourcetree/sourcetreeview.h index 0259c19de..93ba018c5 100644 --- a/src/sourcetree/sourcetreeview.h +++ b/src/sourcetree/sourcetreeview.h @@ -20,14 +20,11 @@ #define SOURCETREEVIEW_H #include "typedefs.h" +#include "sourceplaylistinterface.h" #include #include -namespace Tomahawk { - class PlaylistInterface; -} - class CollectionModel; class PlaylistModel; class SourcesModel;