Bug 236839 - Amarok downloads the album cover while it is already specified by user
Summary: Amarok downloads the album cover while it is already specified by user
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Tools/Cover Manager (show other bugs)
Version: 2.3.0
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-08 13:02 UTC by Alexander Kandaurov
Modified: 2010-05-08 21:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.3.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kandaurov 2010-05-08 13:02:31 UTC
Version:           2.3.0 (using KDE 4.4.1)
Compiler:          gcc-4.3.4 
OS:                Linux
Installed from:    Gentoo Packages

How to reproduce:
1. Run Amarok while using a slow internet connection.
2. Add a new album into the music folder and rescan the collection.
3. (Let's assume that the music in the collection view is shown as "Artist->Album".) When you expand the entry of an artist for which you have added an album, Amarok will start downloading the cover. Immediately after expanding that artist item, set your cover using "Set Custom Cover" option from the context menu of an album.
4. Some time later, the message "Retrieved cover successfully" will appear in the status bar and the cover will be replaced with the downloaded one. You will need to specify the right cover image one more time.
Comment 1 Rick W. Chen 2010-05-08 19:19:49 UTC
commit b191e2cd18462536a9946136b3312af9c6318a10
Author: Rick W. Chen <stuffcorpse@archlinux.us>
Date:   Sun May 9 05:03:43 2010 +1200

    Abort any covers being fetched for an album if one is set manually
    
    BUG: 236839

diff --git a/src/covermanager/CoverFetchQueue.h b/src/covermanager/CoverFetchQueue.h
index ab0f81c..fa626d6 100644
--- a/src/covermanager/CoverFetchQueue.h
+++ b/src/covermanager/CoverFetchQueue.h
@@ -91,13 +91,13 @@ public:
 
 public slots:
     void remove( const CoverFetchUnit::Ptr unit );
+    void remove( const Meta::AlbumPtr album );
 
 signals:
     void fetchUnitAdded( const CoverFetchUnit::Ptr );
 
 private:
     void add( const CoverFetchUnit::Ptr unit );
-    void remove( const Meta::AlbumPtr album );
 
     CoverFetchUnitList m_queue;
     Q_DISABLE_COPY( CoverFetchQueue )
diff --git a/src/covermanager/CoverFetcher.cpp b/src/covermanager/CoverFetcher.cpp
index 8765e78..0cf238d 100644
--- a/src/covermanager/CoverFetcher.cpp
+++ b/src/covermanager/CoverFetcher.cpp
@@ -297,6 +297,7 @@ CoverFetcher::finish( const CoverFetchUnit::Ptr unit,
             debug() << "Finished successfully for album" << albumName;
         }
         album->setImage( m_selectedPixmaps.take( unit ) );
+        m_queue->remove( album );
         break;
 
     case Error:
Comment 2 Rick W. Chen 2010-05-08 21:07:40 UTC
commit e63a115cd70ee9e3dc9fc03d49046f9d4ccc94fa
Author: Rick W. Chen <stuffcorpse@archlinux.us>
Date:   Sun May 9 06:50:19 2010 +1200

    Be more thorough when cleaning up cover fetches
    
    CCBUG:236839

diff --git a/src/covermanager/CoverFetcher.cpp b/src/covermanager/CoverFetcher.cpp
index 0cf238d..e45b882 100644
--- a/src/covermanager/CoverFetcher.cpp
+++ b/src/covermanager/CoverFetcher.cpp
@@ -226,15 +226,7 @@ CoverFetcher::slotDialogFinished()
     foreach( const CoverFetchUnit::Ptr &unit, units )
     {
         if( unit->isInteractive() )
-        {
-            m_queue->remove( unit );
-            m_queueLater.removeAll( unit->album() );
-            m_selectedPixmaps.remove( unit );
-
-            const KJob *job = m_jobs.key( unit );
-            const_cast< KJob* >( job )->deleteLater();
-            m_jobs.remove( job );
-        }
+            abortFetch( unit );
     }
 
     m_dialog->delayedDestruct();
@@ -280,6 +272,18 @@ CoverFetcher::showCover( CoverFetchUnit::Ptr unit, const QPixmap cover, CoverFet
 }
 
 void
+CoverFetcher::abortFetch( CoverFetchUnit::Ptr unit )
+{
+    Meta::AlbumPtr album = unit->album();
+    m_queue->remove( album );
+    m_queueLater.removeAll( album );
+    m_selectedPixmaps.remove( unit );
+    const KJob *job = m_jobs.key( unit );
+    const_cast<KJob*>( job )->deleteLater();
+    m_jobs.remove( job );
+}
+
+void
 CoverFetcher::finish( const CoverFetchUnit::Ptr unit,
                       CoverFetcher::FinishState state,
                       const QString &message )
@@ -297,7 +301,7 @@ CoverFetcher::finish( const CoverFetchUnit::Ptr unit,
             debug() << "Finished successfully for album" << albumName;
         }
         album->setImage( m_selectedPixmaps.take( unit ) );
-        m_queue->remove( album );
+        abortFetch( unit );
         break;
 
     case Error:
diff --git a/src/covermanager/CoverFetcher.h b/src/covermanager/CoverFetcher.h
index 3f5cc53..c56d696 100644
--- a/src/covermanager/CoverFetcher.h
+++ b/src/covermanager/CoverFetcher.h
@@ -72,6 +72,9 @@ private:
     CoverFetcher();
     ~CoverFetcher();
 
+    /// Remove a fetch unit from the queue, and clean up any running jobs
+    void abortFetch( CoverFetchUnit::Ptr unit );
+
     const int m_limit;            //!< maximum number of concurrent fetches
     CoverFetchQueue *m_queue;     //!< current fetch queue
     Meta::AlbumList m_queueLater; //!< put here if m_queue exceeds m_limit