Commit 3e748631 authored by Nicholas Little's avatar Nicholas Little Committed by Andrés G. Aragoneses

Dap.Mtp: Main thread for pixbuf handling (bgo#733659)

It looks like Gdk.Pixbuf gets very unhappy if you don't work with it on
the main thread, even property access generates a gui-thread-check
warning.

In this patch, we block while retrieving the artwork, converting it to a
byte array and recording the geometry.
Signed-off-by: default avatarAndrés G. Aragoneses <knocte@gmail.com>
parent e8f34fb1
......@@ -36,6 +36,7 @@ using Mtp;
using MTP = Mtp;
using Banshee.Dap;
using Banshee.Collection.Gui;
using Banshee.ServiceStack;
using Banshee.Sources;
using Banshee.Playlist;
......@@ -353,16 +354,33 @@ namespace Banshee.Dap.Mtp
album.AddTrack (mtp_track);
if (supports_jpegs && can_sync_albumart) {
ArtworkManager art = ServiceManager.Get<ArtworkManager> ();
Exception ex = null;
Gdk.Pixbuf pic = null;
byte[] bytes = null;
uint width = 0, height = 0;
ThreadAssist.BlockingProxyToMain (() => {
try {
pic = art.LookupScalePixbuf (track.ArtworkId, thumb_width);
if (pic != null) {
bytes = pic.SaveToBuffer ("jpeg");
width = (uint) pic.Width;
height = (uint) pic.Height;
}
} catch (Exception e) {
ex = e;
}
});
try {
Gdk.Pixbuf pic = ServiceManager.Get<Banshee.Collection.Gui.ArtworkManager> ().LookupScalePixbuf (
track.ArtworkId, thumb_width
);
if (pic != null) {
byte [] bytes = pic.SaveToBuffer ("jpeg");
album.Save (bytes, (uint)pic.Width, (uint)pic.Height);
Banshee.Collection.Gui.ArtworkManager.DisposePixbuf (pic);
if (ex != null) {
throw ex;
}
if (bytes != null) {
ArtworkManager.DisposePixbuf (pic);
album.Save (bytes, width, height);
album_cache [key] = album;
}
album_cache[key] = album;
} catch (Exception e) {
Log.Debug ("Failed to create MTP Album", e.Message);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment