QML: Correct threading to load images
authorIvan Frade <ivan.frade@nokia.com>
Tue, 5 Apr 2011 11:41:09 +0000 (14:41 +0300)
committerIvan Frade <ivan.frade@nokia.com>
Tue, 5 Apr 2011 11:41:09 +0000 (14:41 +0300)
src/qml/controller.py

index c0f8d16..618b973 100644 (file)
@@ -23,15 +23,16 @@ class DownloadThread (QtCore.QThread):
 
     def run (self):
         print "Running the thread"
+        MAX_OPTIONS = 4
         counter = 0
-        for x in self.downloader.get_possible_url (self.album.artist,
-                                                   self.album.title, 4):
-            if counter == 4:
+        for img, thumb in self.downloader.get_alternatives (self.album.artist,
+                                                            self.album.title, MAX_OPTIONS):
+            if counter >= MAX_OPTIONS:
                 break
-            print "Setting url", x
-            model.updateData (counter, x)
+
+            print counter, "Setting url", img
+            self.model.updateData (counter, img)
             counter += 1
-        self.exec_ ()
 
 
 class MussorgskyController (QtCore.QObject):