[banshee] [Mtp] Avoid null iterator



commit cd7bd45f517c8092e83f1b2cc0bbcf4ef0ac7d38
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Jul 27 02:45:27 2010 -0700

    [Mtp] Avoid null iterator

 .../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs   |   19 +++++++++++--------
 1 files changed, 11 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 f2172a8..c4d08d0 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -180,15 +180,18 @@ namespace Banshee.Dap.Mtp
                         SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND ExternalID = ?");
 
                 lock (mtp_device) {
-                    foreach (MTP.Playlist playlist in mtp_device.GetPlaylists ()) {
-                        PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
-                        pl_src.Save ();
-                        // TODO a transaction would make sense here (when the threading issue is fixed)
-                        foreach (int id in playlist.TrackIds) {
-                            ServiceManager.DbConnection.Execute (insert_cmd, pl_src.DbId, this.DbId, id);
+                    var playlists = mtp_device.GetPlaylists ();
+                    if (playlists != null) {
+                        foreach (MTP.Playlist playlist in playlists) {
+                            PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
+                            pl_src.Save ();
+                            // TODO a transaction would make sense here (when the threading issue is fixed)
+                            foreach (int id in playlist.TrackIds) {
+                                ServiceManager.DbConnection.Execute (insert_cmd, pl_src.DbId, this.DbId, id);
+                            }
+                            pl_src.UpdateCounts ();
+                            AddChildSource (pl_src);
                         }
-                        pl_src.UpdateCounts ();
-                        AddChildSource (pl_src);
                     }
                 }
 



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