[banshee] Mtp: fix NullReferenceException if playlistFolder wasn't found (bgo#733883)



commit 50bf3cc103841e62f0c9bf0129d63e90eec8f48c
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Sat Aug 2 00:05:56 2014 +0200

    Mtp: fix NullReferenceException if playlistFolder wasn't found (bgo#733883)
    
    There was already a way to try to prevent a NULL playlistFolder
    in the MtpDevice class, but it was insufficient in my case. I'm
    using a Nexus7, and in this case 'device.default_playlist_folder'
    was not 0, but 4294967295 (which apparently is uint.MaxValue).
    
    However, rather than adding yet another magic number in this if
    statement, checking for a NULL playlistFolder at the end of the
    foreach loop seems like a more robust approach.

 src/Libraries/Mtp/Mtp/MtpDevice.cs |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/Libraries/Mtp/Mtp/MtpDevice.cs b/src/Libraries/Mtp/Mtp/MtpDevice.cs
index 155132d..89267da 100644
--- a/src/Libraries/Mtp/Mtp/MtpDevice.cs
+++ b/src/Libraries/Mtp/Mtp/MtpDevice.cs
@@ -152,10 +152,6 @@ namespace Mtp
                     albumFolder = f;
                 else if (f.FolderId == device.default_music_folder) {
                     musicFolder = f;
-                    // Fix for devices that don't have an explicit playlist folder (BGO #590342)
-                    if (device.default_playlist_folder == 0) {
-                        playlistFolder = f;
-                    }
                 }
                 else if (f.FolderId == device.default_organizer_folder)
                     organizerFolder = f;
@@ -170,6 +166,11 @@ namespace Mtp
                 else if (f.FolderId == device.default_zencast_folder)
                     podcastFolder = f;
             }
+
+            // Fix for devices that don't have an explicit playlist folder (see BGO #590342 and #733883)
+            if (playlistFolder == null && musicFolder != null) {
+                playlistFolder = musicFolder;
+            }
         }
         
         public void Dispose ()


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