diff --git a/src/libtomahawk/jobview/LatchedStatusItem.cpp b/src/libtomahawk/jobview/LatchedStatusItem.cpp index 4041d2abe..c4dee5c19 100644 --- a/src/libtomahawk/jobview/LatchedStatusItem.cpp +++ b/src/libtomahawk/jobview/LatchedStatusItem.cpp @@ -80,9 +80,26 @@ LatchedStatusManager::latchedOn( const Tomahawk::source_ptr& from, const Tomahaw LatchedStatusItem* item = new LatchedStatusItem( from, to, this ); m_jobs[ from->userName() ] = item; JobStatusView::instance()->model()->addJob( item ); + + connect( from.data(), SIGNAL( offline() ), this, SLOT( sourceOffline() ), Qt::UniqueConnection ); } } +void +LatchedStatusManager::sourceOffline() +{ + Tomahawk::Source* s = qobject_cast< Tomahawk::Source* >( sender() ); + Q_ASSERT( s ); + + if ( m_jobs.contains( s->userName() ) ) + { + QWeakPointer< LatchedStatusItem> job = m_jobs.take( s->userName() ).data(); + if ( !job.isNull() ) + job.data()->stop(); + } +} + + void LatchedStatusManager::latchedOff( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to ) { diff --git a/src/libtomahawk/jobview/LatchedStatusItem.h b/src/libtomahawk/jobview/LatchedStatusItem.h index c67fccef2..7f7cb3f8a 100644 --- a/src/libtomahawk/jobview/LatchedStatusItem.h +++ b/src/libtomahawk/jobview/LatchedStatusItem.h @@ -56,6 +56,7 @@ public: private slots: void latchedOn( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& ); void latchedOff( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& ); + void sourceOffline(); private: QPixmap m_pixmap;