From 7403713d98afaccd4dc2ce7a27c22e284b4b4511 Mon Sep 17 00:00:00 2001
From: Christian Muehlhaeuser <muesli@gmail.com>
Date: Sat, 31 Mar 2012 08:44:07 +0200
Subject: [PATCH] * Only connect to InfoSystem on demand.

---
 src/libtomahawk/album.cpp  | 21 ++++++++++++++-------
 src/libtomahawk/artist.cpp | 22 ++++++++++++++--------
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/src/libtomahawk/album.cpp b/src/libtomahawk/album.cpp
index a280f4905..3b52e7166 100644
--- a/src/libtomahawk/album.cpp
+++ b/src/libtomahawk/album.cpp
@@ -82,13 +82,6 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
     , m_cover( 0 )
 #endif
 {
-    connect( Tomahawk::InfoSystem::InfoSystem::instance(),
-             SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
-             SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
-    
-    connect( Tomahawk::InfoSystem::InfoSystem::instance(),
-             SIGNAL( finished( QString ) ),
-             SLOT( infoSystemFinished( QString ) ) );
 }
 
 
@@ -131,6 +124,14 @@ Album::cover( const QSize& size, bool forceLoad ) const
         requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
         requestData.customData = QVariantMap();
 
+        connect( Tomahawk::InfoSystem::InfoSystem::instance(),
+                SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
+                SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
+        
+        connect( Tomahawk::InfoSystem::InfoSystem::instance(),
+                SIGNAL( finished( QString ) ),
+                SLOT( infoSystemFinished( QString ) ) );
+
         Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
     }
 
@@ -190,6 +191,12 @@ Album::infoSystemFinished( QString target )
     if ( target != m_uuid )
         return;
 
+    disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
+                this, SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
+        
+    disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ),
+                this, SLOT( infoSystemFinished( QString ) ) );
+
     m_infoLoaded = true;
     emit updated();
 }
diff --git a/src/libtomahawk/artist.cpp b/src/libtomahawk/artist.cpp
index dc22a0861..d2b124240 100644
--- a/src/libtomahawk/artist.cpp
+++ b/src/libtomahawk/artist.cpp
@@ -82,14 +82,6 @@ Artist::Artist( unsigned int id, const QString& name )
 #endif
 {
     m_sortname = DatabaseImpl::sortname( name, true );
-
-    connect( Tomahawk::InfoSystem::InfoSystem::instance(),
-             SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
-             SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
-    
-    connect( Tomahawk::InfoSystem::InfoSystem::instance(),
-             SIGNAL( finished( QString ) ),
-             SLOT( infoSystemFinished( QString ) ) );
 }
 
 
@@ -122,6 +114,14 @@ Artist::cover( const QSize& size, bool forceLoad ) const
         requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
         requestData.customData = QVariantMap();
 
+        connect( Tomahawk::InfoSystem::InfoSystem::instance(),
+                SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
+                SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
+        
+        connect( Tomahawk::InfoSystem::InfoSystem::instance(),
+                SIGNAL( finished( QString ) ),
+                SLOT( infoSystemFinished( QString ) ) );
+
         Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
     }
 
@@ -181,6 +181,12 @@ Artist::infoSystemFinished( QString target )
     if ( target != m_uuid )
         return;
 
+    disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
+                this, SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
+        
+    disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ),
+                this, SLOT( infoSystemFinished( QString ) ) );
+
     m_infoLoaded = true;
     emit updated();
 }