Commits

Iñigo Serna committed 78f098b

Minor changes regarding load covers in background

  • Participants
  • Parent commits f4f4cb3

Comments (0)

Files changed (2)

 
 
 import time
-import gc
 
 import pygtk
 pygtk.require('2.0')
         lib = self.cfg.active_lib
         dlg = DialogProgress('Loading library', db.get_books_count(), self, True)
         for num in self.populate_model(lib):
-            if num % 50 == 0:
-                dlg.update(num)
-                process_events()
+            dlg.update(num)
+            process_events()
         dlg.elliminate()
         # update ui
         self.viewmode = None
         if msg is not None:
             self.libsbar.update_message(msg)
         self.libsbar.update_books('Showing %d books' % len(self.ids_all))
+        self.cover_factory.reinitialize()
 
 
     def init_ui(self):
         self.model.clear()
         del self.ids_all[:]
         del self.ids_filtered[:]
-        log.debug('Calling garbage collector')
-        gc.collect()
         for i, b in enumerate(db.get_books()):
             self.model.append(b.to_modelrow())
             self.ids_all.append(b.id)
             self.ids_filtered.append(b.id)
-            if i % 10 == 0:
+            if i % 50 == 0:
                 yield i
-        self.cover_factory.reinitialize()
-        gc.collect()
         self.model.set_sort_column_id(lib.sort_col[0], lib.sort_col[1])
         # self.listview.thaw_child_notify()
         # self.prettyview.thaw_child_notify()

File ui/ui_common.py

 # -*- coding: utf-8 -*-
 
+
+import gc
 from random import randrange
 
 import gtk
         self.algo = DEFAULT_ALGO
         self.__books_generator = None
         self.__idle_fn_id = None
-        self.get = None
+        self.get = self.get_cover_temp
 
 
     def reinitialize(self):
         self.cache.clear()
         self.default_cache.clear()
+        log.debug('Calling garbage collector')
+        gc.collect()
         if self.__idle_fn_id is not None:
             gobject.idle_remove(self.__idle_fn_id)
         self.__books_generator = db.book_generator_id_path_hascover()
         self.__idle_fn_id = gobject.idle_add(self.idle_load_covers)
-        log.debug('Start: load covers in background')
+        log.debug('START load covers in background')
         self.get = self.get_cover_temp
 
 
         try:
             book_id, book_path, has_cover = self.__books_generator.next()
         except StopIteration:
-            log.debug('End: load covers in background')
+            log.debug('END load covers in background')
             self.__idle_fn_id = None
             self.get = self.get_cover_ok
             return False