[banshee] MtpSource: prevent a freeze when dealing with Windows Phone (bgo#687495)



commit d4fbe62ad024083739c07b4f7c7d75037fba7a14
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Wed May 22 14:48:22 2013 +0100

    MtpSource: prevent a freeze when dealing with Windows Phone (bgo#687495)
    
    An ArgumentNullException was raised when accessing the BytesUsed property
    of MtpSource class, which can be easily avoided by checking for null first.
    If mtp_device is null it means that its initialization has not succeded,
    something which should be logged by the DeviceInitialize() method.

 .../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs   |    2 +-
 1 files changed, 1 insertions(+), 1 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 e7cd000..c3670f7 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -294,7 +294,7 @@ namespace Banshee.Dap.Mtp
         private long bytes_used;
         public override long BytesUsed {
             get {
-                if (Monitor.TryEnter (mtp_device)) {
+                if (mtp_device != null && Monitor.TryEnter (mtp_device)) {
                     try {
                         bytes_used = 0;
                         foreach (DeviceStorage s in mtp_device.GetStorage ()) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]