Lock when changing album art

If we lock, then we prevent the possibility that multiple threads will
attempt to change the art at the same time.  We hold the lock until
after the resize for the same reason.
This commit is contained in:
Bryan Schumaker 2010-11-01 11:53:59 -04:00
parent 5a6b321ffe
commit af7151a554
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,10 @@
import libsaria import libsaria
import gtk import gtk
from libsaria import threads
lock = threads.get_mutex("album_art")
class Image(gtk.Image): class Image(gtk.Image):
def __init__(self): def __init__(self):
gtk.Image.__init__(self) gtk.Image.__init__(self)
@ -34,11 +38,13 @@ class AlbumArt(Image):
self.file = "images/ocarina.png" self.file = "images/ocarina.png"
def set(self, file=None): def set(self, file=None):
lock.acquire()
if file != None: if file != None:
self.file = file self.file = file
self.set_from_file(self.file) self.set_from_file(self.file)
self.set_height(64) self.set_height(64)
self.show() self.show()
lock.release()
def set_height(self, new_h): def set_height(self, new_h):
size = self.size_request() size = self.size_request()