[banshee] Dap.Mtp: Main thread for pixbuf handling (bgo#733659)
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Dap.Mtp: Main thread for pixbuf handling (bgo#733659)
- Date: Wed, 30 Jul 2014 19:15:35 +0000 (UTC)
commit 3e748631a9437d3f1e74f890d0e9af31a9680481
Author: Nicholas Little <arealityfarbetween googlemail com>
Date: Wed Jul 30 21:09:46 2014 +0200
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: Andrés G. Aragoneses <knocte gmail com>
.../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs | 34 +++++++++++++++-----
1 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
index 3ef48ff..bf3eb6a 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]